<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>

  <groupId>ch.so.agi.gretl</groupId>
  <artifactId>gretl-runtime-parent</artifactId>
  <version>0.1.0-SNAPSHOT</version>
  <packaging>pom</packaging>

  <name>GRETL Runtime Parent</name>
  <description>
    Root parent and aggregator for the GRETL Runtime product build:
    API, runner, Groovy adapter, logging, standard tasks, CLI, packager and
    packaged job runtime.
  </description>

  <modules>
    <module>gretl-api</module>
    <module>gretl-runner</module>
    <module>gretl-groovy</module>
    <module>gretl-i18n</module>
    <module>gretl-logging</module>
    <module>gretl-packager</module>
    <module>gretl-database-tasks</module>
    <module>gretl-io-tasks</module>
    <module>gretl-cli</module>
    <module>gretl-job-runtime</module>
    <module>gretl-ilivalidator</module>
    <module>gretl-interlis-tasks</module>
    <module>examples/file-size-extension</module>
    <module>gretl-dist</module>
    <module>gretl-integration-tests</module>
  </modules>

  <properties>
    <gretl.sourceRevision></gretl.sourceRevision>
    <!-- Product baseline, spec 07. The wrapper pins Maven 3.10.0 separately. -->
    <java.version>25</java.version>
    <gretl.test.includes>**/*JobIT.java</gretl.test.includes>
    <gretl.test.executionMode>SCRIPT</gretl.test.executionMode>
    <maven.build.timestamp.format>yyyyMMddHHmmssSSS</maven.build.timestamp.format>
    <gretl.test.runId>${maven.build.timestamp}</gretl.test.runId>
    <jacoco.version>0.8.14</jacoco.version>
    <maven.compiler.release>25</maven.compiler.release>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>

    <groovy.version>6.0.0</groovy.version>
    <junit.version>5.14.4</junit.version>
    <slf4j.version>2.0.20</slf4j.version>
    <logback.version>1.6.5</logback.version>
    <postgresql.version>42.7.14</postgresql.version>
    <ilivalidator.version>1.15.0</ilivalidator.version>
    <ili2c.version>5.6.8</ili2c.version>
    <iox-ili.version>1.24.4</iox-ili.version>
    <ili2pg.version>5.5.1</ili2pg.version>
    <ili2gpkg.version>5.5.1</ili2gpkg.version>
    <ili2duckdb.version>5.5.1</ili2duckdb.version>
    <ehisqlgen.version>1.16.3</ehisqlgen.version>
    <av2ch.version>1.1.8</av2ch.version>
    <av2geobau.version>1.4.2</av2geobau.version>
    <iox-wkf.version>2.0.1-20250417.084407-2</iox-wkf.version>
    <iox-formats.version>1.0.3</iox-formats.version>
    <ilivalidator-custom-functions.version>1.1.50</ilivalidator-custom-functions.version>
    <ilivalidator-custom-functions-geometries.version>0.0.8</ilivalidator-custom-functions-geometries.version>
    <geow-interlis-functions.version>0.2.1</geow-interlis-functions.version>
    <interlis-functions-ngk-so.version>1.0.3</interlis-functions-ngk-so.version>
    <geotools.version>35.2</geotools.version>
    <saxon.version>11.4</saxon.version>
    <xmlresolver.version>4.4.3</xmlresolver.version>
    <commons-net.version>3.6</commons-net.version>
    <mockftpserver.version>2.7.1</mockftpserver.version>
    <testcontainers.version>1.21.4</testcontainers.version>
    <testcontainers-floci.version>1.10.0</testcontainers-floci.version>
    <aws-sdk.version>2.15.64</aws-sdk.version>
    <duckdb.version>1.5.2.0</duckdb.version>
    <commons-io.version>2.18.0</commons-io.version>
    <poi.version>5.2.5</poi.version>
    <jackson.version>2.17.2</jackson.version>
    <sqlite-jdbc.version>3.53.2.0</sqlite-jdbc.version>
    <commons-compress.version>1.27.1</commons-compress.version>
  </properties>

  <dependencyManagement>
    <dependencies>
      <dependency>
        <groupId>org.junit</groupId>
        <artifactId>junit-bom</artifactId>
        <version>${junit.version}</version>
        <type>pom</type>
        <scope>import</scope>
      </dependency>
      <dependency>
        <groupId>com.fasterxml.jackson.core</groupId>
        <artifactId>jackson-core</artifactId>
        <version>${jackson.version}</version>
      </dependency>
      <dependency>
        <groupId>com.fasterxml.jackson.core</groupId>
        <artifactId>jackson-databind</artifactId>
        <version>${jackson.version}</version>
      </dependency>
      <dependency>
        <groupId>com.fasterxml.jackson.core</groupId>
        <artifactId>jackson-annotations</artifactId>
        <version>${jackson.version}</version>
      </dependency>
      <dependency>
        <groupId>ch.interlis</groupId>
        <artifactId>ili2c-core</artifactId>
        <version>${ili2c.version}</version>
      </dependency>
      <dependency>
        <groupId>ch.interlis</groupId>
        <artifactId>ili2c-tool</artifactId>
        <version>${ili2c.version}</version>
      </dependency>
      <dependency>
        <groupId>ch.interlis</groupId>
        <artifactId>iox-ili</artifactId>
        <version>${iox-ili.version}</version>
      </dependency>
      <dependency>
        <groupId>ch.interlis</groupId>
        <artifactId>ili2pg</artifactId>
        <version>${ili2pg.version}</version>
      </dependency>
      <dependency>
        <groupId>ch.interlis</groupId>
        <artifactId>ili2gpkg</artifactId>
        <version>${ili2gpkg.version}</version>
      </dependency>
      <dependency>
        <groupId>org.apache.poi</groupId>
        <artifactId>poi</artifactId>
        <version>${poi.version}</version>
      </dependency>
      <dependency>
        <groupId>org.apache.poi</groupId>
        <artifactId>poi-ooxml</artifactId>
        <version>${poi.version}</version>
      </dependency>
      <dependency>
        <groupId>commons-io</groupId>
        <artifactId>commons-io</artifactId>
        <version>${commons-io.version}</version>
      </dependency>
      <dependency>
        <groupId>ch.interlis</groupId>
        <artifactId>ili2db</artifactId>
        <version>${ili2pg.version}</version>
      </dependency>
      <dependency>
        <groupId>ch.interlis</groupId>
        <artifactId>iox-api</artifactId>
        <version>1.0.4</version>
      </dependency>
      <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-api</artifactId>
        <version>${slf4j.version}</version>
      </dependency>
    </dependencies>
  </dependencyManagement>

  <build>
    <pluginManagement>
      <plugins>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-clean-plugin</artifactId>
          <version>3.5.0</version>
        </plugin>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-resources-plugin</artifactId>
          <version>3.5.0</version>
        </plugin>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-compiler-plugin</artifactId>
          <version>3.16.0</version>
        </plugin>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-surefire-plugin</artifactId>
          <version>3.6.0</version>
        </plugin>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-jar-plugin</artifactId>
          <version>3.5.1</version>
        </plugin>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-assembly-plugin</artifactId>
          <version>3.7.1</version>
        </plugin>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-failsafe-plugin</artifactId>
          <version>3.6.0</version>
        </plugin>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-dependency-plugin</artifactId>
          <version>3.11.0</version>
        </plugin>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-antrun-plugin</artifactId>
          <version>3.1.0</version>
        </plugin>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-install-plugin</artifactId>
          <version>3.2.0</version>
        </plugin>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-deploy-plugin</artifactId>
          <version>3.2.0</version>
        </plugin>
        <plugin>
          <groupId>org.codehaus.mojo</groupId>
          <artifactId>build-helper-maven-plugin</artifactId>
          <version>3.6.1</version>
        </plugin>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-enforcer-plugin</artifactId>
          <version>3.6.3</version>
        </plugin>
      </plugins>
    </pluginManagement>

    <plugins>
      <!-- Java 25 coverage for test JVMs; forked product processes are reported separately. -->
      <plugin>
        <groupId>org.jacoco</groupId>
        <artifactId>jacoco-maven-plugin</artifactId>
        <version>${jacoco.version}</version>
        <executions>
          <execution>
            <id>coverage-agent</id>
            <goals><goal>prepare-agent</goal></goals>
            <configuration><append>true</append></configuration>
          </execution>
          <execution>
            <id>coverage-report</id>
            <phase>verify</phase>
            <goals><goal>report</goal></goals>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-enforcer-plugin</artifactId>
        <executions>
          <execution>
            <id>enforce-product-toolchain</id>
            <phase>validate</phase>
            <goals>
              <goal>enforce</goal>
            </goals>
            <configuration>
              <rules>
                <requireJavaVersion>
                  <version>[25,26)</version>
                  <message>
                    GRETL Runtime must be built with a Java 25 toolchain.
                    Set JAVA_HOME to the qualified JDK 25 before running ./mvnw.
                  </message>
                </requireJavaVersion>
                <requireMavenVersion>
                  <version>[3.10.0,3.11)</version>
                  <message>
                    GRETL Runtime must be built with the repository Maven wrapper
                    (Maven 3.10.0). Use ./mvnw, not an arbitrary system Maven.
                  </message>
                </requireMavenVersion>
              </rules>
            </configuration>
          </execution>
          <execution>
            <id>ban-geotools</id>
            <phase>validate</phase>
            <goals>
              <goal>enforce</goal>
            </goals>
            <configuration>
              <rules>
                <bannedDependencies>
                  <searchTransitive>true</searchTransitive>
                  <excludes>
                    <exclude>org.geotools:*</exclude>
                    <exclude>org.geotools.ogc:*</exclude>
                  </excludes>
                  <message>
                    GeoTools is restricted to the explicit -Pgeotools-probe
                    qualification profile. Core and task modules must stay free
                    of GeoTools dependencies.
                  </message>
                </bannedDependencies>
              </rules>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <configuration>
          <release>${maven.compiler.release}</release>
          <encoding>${project.build.sourceEncoding}</encoding>
          <compilerArgs>
            <arg>-Xlint:all</arg>
          </compilerArgs>
        </configuration>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <configuration>
          <!-- JUnit Platform is auto-detected from the Jupiter engine on the test classpath. -->
          <trimStackTrace>false</trimStackTrace>
        </configuration>
      </plugin>
    </plugins>
  </build>

  <profiles>
    <profile>
      <id>publish-snapshots</id>
      <distributionManagement>
        <snapshotRepository>
          <id>interlis-snapshots</id>
          <url>https://jars.interlis.guru/snapshots</url>
        </snapshotRepository>
      </distributionManagement>
    </profile>

    <!--
      The GeoTools probe is an explicitly separated compatibility qualification profile.
      It is not part of the default product build and its test dependencies are
      not part of any runtime or standard distribution artifact.
    -->
    <profile>
      <id>geotools-probe</id>
      <modules>
        <module>gretl-geotools-probe</module>
      </modules>
    </profile>

    <!--
      Docker-backed integration tests for real backing services. Deliberately
      opt-in: the default verify build stays Docker-free.
    -->
    <profile>
      <id>backing-services</id>
      <properties><gretl.test.includes>**/*IT.java</gretl.test.includes></properties>
    </profile>
    <profile>
      <id>job-image</id>
      <properties><gretl.test.executionMode>IMAGE</gretl.test.executionMode></properties>
      <build><plugins><plugin>
        <groupId>org.apache.maven.plugins</groupId><artifactId>maven-enforcer-plugin</artifactId>
        <executions><execution><id>require-image-mode</id><phase>validate</phase><goals><goal>enforce</goal></goals>
          <configuration><rules><requireProperty><property>gretl.test.executionMode</property><regex>IMAGE</regex><message>job-image requires executionMode=IMAGE</message></requireProperty></rules></configuration>
        </execution></executions>
      </plugin></plugins></build>
    </profile>
  </profiles>
</project>
