<?xml version="1.0" encoding="UTF-8"?>
<!--
  Licensed under the Apache License, Version 2.0 (the "License");
  you may not use this file except in compliance with the License.
  You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License. See accompanying LICENSE file.
-->
<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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.minsait.onesait.platform</groupId>
  <artifactId>dataflow-api</artifactId>
  <version>4.0.0</version>
  <description>Onesait Platform Dataflow API</description>
  <name>Minsait Onesait Platform Dataflow API</name>
  <packaging>jar</packaging>
  <scm>
    <url>https://github.com/streamsets/datacollector-api</url>
  </scm>

  <organization>
    <name>Minsait Onesait Platform</name>
    <url>http://www.streamsets.com</url>
  </organization>

  <licenses>
    <license>
      <name>The Apache Software License, Version 2.0</name>
      <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
    </license>
  </licenses>

  <properties>
    <!-- required JDK version -->
    <javaVersion>21</javaVersion>

    <!-- Testcases output redirection -->
    <maven.test.redirectTestOutputToFile>true</maven.test.redirectTestOutputToFile>
    <maven.deploy.skip>false</maven.deploy.skip>

    <!-- Platform encoding override -->
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>

    <!-- Dependency Versions

         All dependency versions should be defined here to avoid version
         mismatches with multiple artifacts of the same logical dependency.
    -->
    <guava.version>18.0</guava.version>
    <jacoco.version>0.8.12</jacoco.version>
    <jetbrains.annotations.version>19.0.0</jetbrains.annotations.version>
    <junit.version>5.14.0</junit.version>
    <reload4j.version>1.2.25</reload4j.version>
    <metrics.version>3.1.2</metrics.version>
    <mockito.version>5.20.0</mockito.version>
    <slf4j.version>2.0.7</slf4j.version>
  </properties>


  <distributionManagement>
    <repository>
      <id>releases</id>
      <url>https://nexus.onesaitplatform.com/nexus/repository/releases/</url>
      <releases>
        <enabled>true</enabled>
      </releases>
    </repository>
  </distributionManagement>

  <dependencies>
    <dependency>
      <groupId>org.slf4j</groupId>
      <artifactId>slf4j-api</artifactId>
      <version>${slf4j.version}</version>
      <scope>compile</scope>
    </dependency>
    <dependency>
      <groupId>io.dropwizard.metrics</groupId>
      <artifactId>metrics-core</artifactId>
      <version>${metrics.version}</version>
      <scope>compile</scope>
    </dependency>
    <!--
      This dependency is needed only at compile time, not at runtime
      Maven does not have the equivalent of Gradle's compileOnly.
      We can mark it provided and simply not provide it at runtime to
      avoid leaking it.
     -->
    <!-- Keeping it as scope compile till all dependents are fixed -->
    <dependency>
      <groupId>org.jetbrains</groupId>
      <artifactId>annotations</artifactId>
      <version>${jetbrains.annotations.version}</version>
      <scope>compile</scope>
    </dependency>

    <dependency>
      <groupId>org.junit.jupiter</groupId>
      <artifactId>junit-jupiter</artifactId>
      <version>${junit.version}</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.mockito</groupId>
      <artifactId>mockito-core</artifactId>
      <version>${mockito.version}</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>com.google.guava</groupId>
      <artifactId>guava</artifactId>
      <version>${guava.version}</version>
      <scope>test</scope>
    </dependency>
  </dependencies>

  <profiles>
    <profile>
      <id>sign</id>
      <build>
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-gpg-plugin</artifactId>
            <executions>
              <execution>
                <phase>verify</phase>
                <goals>
                  <goal>sign</goal>
                </goals>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>
    <profile>
      <id>javadoc-java21</id>
      <activation>
        <activeByDefault>false</activeByDefault>
        <jdk>21</jdk>
      </activation>
      <build>
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-javadoc-plugin</artifactId>
            <configuration>
              <additionalparam>-Xdoclint:none</additionalparam>
            </configuration>
          </plugin>
        </plugins>
      </build>
    </profile>
  </profiles>

  <build>
    <resources>
      <resource>
        <directory>${basedir}/src/main/resources</directory>
        <excludes>
          <exclude>pipeline-api-build-info.properties</exclude>
        </excludes>
        <filtering>false</filtering>
      </resource>
      <resource>
        <directory>${basedir}/src/main/resources</directory>
        <includes>
          <include>pipeline-api-build-info.properties</include>
        </includes>
        <filtering>true</filtering>
      </resource>
    </resources>
    <pluginManagement>
      <plugins>
        <plugin>
          <groupId>org.jacoco</groupId>
          <artifactId>jacoco-maven-plugin</artifactId>
          <version>${jacoco.version}</version>
          <executions>
            <!--
                Prepares the property pointing to the JaCoCo runtime agent which
                is passed as VM argument when Maven the Surefire plugin is executed.
            -->
            <execution>
              <id>pre-unit-test</id>
              <goals>
                <goal>prepare-agent</goal>
              </goals>
              <configuration>
                <!-- Sets the path to the file which contains the execution data. -->
                <destFile>${project.build.directory}/coverage-reports/jacoco-ut.exec</destFile>
                <append>true</append>
              </configuration>
            </execution>
            <!--
                Ensures that the code coverage report for unit tests is created after
                unit tests have been run.
            -->
            <execution>
              <id>post-unit-test</id>
              <phase>test</phase>
              <goals>
                <goal>report</goal>
              </goals>
              <configuration>
                <!-- Sets the path to the file which contains the execution data. -->
                <dataFile>${project.build.directory}/coverage-reports/jacoco-ut.exec</dataFile>
                <!-- Sets the output directory for the code coverage report. -->
                <outputDirectory>${project.reporting.outputDirectory}/jacoco-ut</outputDirectory>
              </configuration>
            </execution>
            <!-- The Executions required by unit tests are omitted. -->
            <!--
                Prepares the property pointing to the JaCoCo runtime agent which
                is passed as VM argument when Maven the Failsafe plugin is executed.
            -->
            <execution>
              <id>pre-integration-test</id>
              <phase>pre-integration-test</phase>
              <goals>
                <goal>prepare-agent</goal>
              </goals>
              <configuration>
                <!-- Sets the path to the file which contains the execution data. -->
                <destFile>${project.build.directory}/coverage-reports/jacoco-it.exec</destFile>
                <append>true</append>
              </configuration>
            </execution>
            <!--
                Ensures that the code coverage report for integration tests after
                integration tests have been run.
            -->
            <execution>
              <id>post-integration-test</id>
              <phase>post-integration-test</phase>
              <goals>
                <goal>report</goal>
              </goals>
              <configuration>
                <!-- Sets the path to the file which contains the execution data. -->
                <dataFile>${project.build.directory}/coverage-reports/jacoco-it.exec</dataFile>
                <!-- Sets the output directory for the code coverage report. -->
                <outputDirectory>${project.reporting.outputDirectory}/jacoco-it</outputDirectory>
              </configuration>
            </execution>
          </executions>
        </plugin>
      </plugins>
    </pluginManagement>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-enforcer-plugin</artifactId>
        <version>1.3.1</version>
        <configuration>
          <rules>
            <requireMavenVersion>
              <version>[3.2.1,)</version>
            </requireMavenVersion>
            <requireJavaVersion>
              <version>${javaVersion}</version>
            </requireJavaVersion>
          </rules>
        </configuration>
      </plugin>
      <plugin>
        <groupId>org.openrewrite.maven</groupId>
        <artifactId>rewrite-maven-plugin</artifactId>
        <version>6.22.1</version>
        <configuration>
          <configLocation>${maven.multiModuleProjectDirectory}/rewrite.yml</configLocation>
          <runPerSubmodule>true</runPerSubmodule>
          <skipMavenParsing>true</skipMavenParsing>

          <activeRecipes>
            <recipe>com.minsait.onesait.platform.dataflow.recipes.ChangePackages</recipe>
          </activeRecipes>

          <exclusions>
            <exclusion>rewrite.yml</exclusion>
            <exclusion>**/rewrite.yml</exclusion>
            <exclusion>**/.rewrite/**</exclusion>
            <exclusion>docs/**</exclusion>
            <exclusion>docker/**</exclusion>
            <exclusion>**/*.tgz</exclusion>
            <exclusion>**/libs/**</exclusion>
            <exclusion>**/dist/**</exclusion>
            <exclusion>**/build/**</exclusion>
          </exclusions>

          <additionalPlainTextMasks>
            <additionalPlainTextMask>**/*.yml</additionalPlainTextMask>
            <additionalPlainTextMask>**/*.yaml</additionalPlainTextMask>
            <additionalPlainTextMask>**/*.properties</additionalPlainTextMask>
            <additionalPlainTextMask>**/*.bnd</additionalPlainTextMask>
          </additionalPlainTextMasks>

          <recipeChangeLogLevel>INFO</recipeChangeLogLevel>
        </configuration>
      </plugin>

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.13.0</version>
        <configuration>
          <release>${javaVersion}</release>
          <parameters>true</parameters>
        </configuration>
        <executions>
          <execution>
            <id>default-compile</id>
            <goals><goal>compile</goal></goals>
            <configuration>
              <proc>none</proc>
            </configuration>
          </execution>
          <execution>
            <id>default-testCompile</id>
            <goals><goal>testCompile</goal></goals>
          </execution>
        </executions>
      </plugin>

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <version>3.2.5</version>
      </plugin>
      <plugin>
        <groupId>org.jacoco</groupId>
        <artifactId>jacoco-maven-plugin</artifactId>
      </plugin>
      <plugin>
        <groupId>org.apache.hadoop</groupId>
        <artifactId>hadoop-maven-plugins</artifactId>
        <version>2.6.0</version>
        <executions>
          <execution>
            <id>version-info</id>
            <phase>generate-resources</phase>
            <goals>
              <goal>version-info</goal>
            </goals>
            <configuration>
              <source>
                <directory>${basedir}/src/main</directory>
                <includes>
                  <include>java/**/*.java</include>
                </includes>
              </source>
            </configuration>
          </execution>
        </executions>
      </plugin>

      <plugin>
        <groupId>org.apache.rat</groupId>
        <artifactId>apache-rat-plugin</artifactId>
        <version>0.12</version>
        <configuration>
          <excludes>

            <exclude>CHANGES.txt</exclude>

            <exclude>.idea/**</exclude>
            <exclude>.m2/**</exclude>
            <exclude>**/*.iml</exclude>

            <exclude>.git/**</exclude>
            <exclude>.gitignore</exclude>
            <exclude>.gitreview</exclude>

	    <!-- Jenkins -->
            <exclude>**/buildInfo*.properties</exclude>
	    <exclude>**/ok</exclude>
	    <exclude>**/classworlds*conf</exclude>

            <exclude>**/target/**</exclude>

            <exclude>**/*.json</exclude>

            <exclude>src/main/resources/META-INF/services/**</exclude>

          </excludes>
        </configuration>
        <executions>
          <execution>
            <id>rat-check</id>
            <phase>package</phase>
            <goals>
              <goal>check</goal>
            </goals>
          </execution>
        </executions>
      </plugin>

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-source-plugin</artifactId>
        <version>3.2.0</version>
        <executions>
          <execution>
            <id>attach-sources</id>
            <goals>
              <goal>jar</goal>
            </goals>
          </execution>
        </executions>
      </plugin>

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-javadoc-plugin</artifactId>
        <version>3.6.3</version>
        <executions>
          <execution>
            <id>javadoc</id>
            <phase>prepare-package</phase>
            <goals>
              <goal>javadoc</goal>
              <goal>jar</goal>
            </goals>
            <configuration>
              <doclint>none</doclint>
              <detectJavaApiLink>true</detectJavaApiLink>
              <quiet>true</quiet>
              <charset>UTF-8</charset>
              <excludePackageNames>
                com.minsait.onesait.platform.pipeline.api.impl:com.minsait.onesait.platform.pipeline.api.ext
              </excludePackageNames>
              <groups>
                <group>
                  <title>Dataflow API</title>
                  <packages>com.minsait.onesait.platform.pipeline.api:com.minsait.onesait.platform.pipeline.api.*</packages>
                </group>
              </groups>
            </configuration>
          </execution>
        </executions>
      </plugin>

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-deploy-plugin</artifactId>
        <version>2.8.2</version>
        <configuration>
          <skip>${maven.deploy.skip}</skip>
        </configuration>
      </plugin>

    </plugins>
  </build>

  <reporting>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-project-info-reports-plugin</artifactId>
        <version>2.8</version>
        <configuration>
          <dependencyLocationsEnabled>false</dependencyLocationsEnabled>
          <dependencyDetailsEnabled>false</dependencyDetailsEnabled>
        </configuration>
        <reportSets>
          <reportSet>
            <reports>
              <report>dependencies</report>
            </reports>
          </reportSet>
        </reportSets>
      </plugin>
    </plugins>
  </reporting>

</project>
