<?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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>

  <parent>
    <groupId>org.camunda</groupId>
    <artifactId>camunda-release-parent</artifactId>
    <version>3.9.1</version>
    <!-- do not remove empty tag - http://jira.codehaus.org/browse/MNG-4687 -->
    <relativePath/>
  </parent>

  <groupId>io.zeebe</groupId>
  <artifactId>zeebe-test-container</artifactId>
  <version>3.3.0</version>
  <packaging>jar</packaging>
  <name>Zeebe Test Container</name>
  <url>https://github.com/zeebe-io/zeebe-test-container</url>
  <inceptionYear>2019</inceptionYear>

  <scm>
    <connection>scm:git:git@github.com:camunda-community-hub/zeebe-test-container.git</connection>
    <developerConnection>scm:git:git@github.com:camunda-community-hub/zeebe-test-container.git</developerConnection>
    <tag>HEAD</tag>
    <url>https://github.com/camunda-community-hub/zeebe-test-container</url>
  </scm>

  <properties>
    <!-- release parent settings -->
    <version.java>1.8</version.java>
    <nexus.snapshot.repository>https://app.camunda.com/nexus/content/repositories/zeebe-io-snapshots/</nexus.snapshot.repository>
    <nexus.release.repository>https://app.camunda.com/nexus/content/repositories/zeebe-io/</nexus.release.repository>

    <!-- disable jdk8 javadoc checks on release build -->
    <additionalparam>-Xdoclint:none</additionalparam>

    <!--
      you can use the following to disable specific checks. the approach taken is to use a single
      new property, skipChecks, which is the default value for pre-defined properties such as
      checkstyle.skip. that way, you can use skipChecks, but you can also still use checkstyle.skip
      if you only want to disable checkstyle
      -->
    <skipChecks>false</skipChecks>
    <checkstyle.skip>${skipChecks}</checkstyle.skip>
    <dependency-check.skip>${skipChecks}</dependency-check.skip>
    <enforcer.skip>${skipChecks}</enforcer.skip>
    <mdep.analyze.skip>${skipChecks}</mdep.analyze.skip>
    <revapi.skip>${skipChecks}</revapi.skip>
    <spotless.check.skip>${skipChecks}</spotless.check.skip>

    <!-- project dependencies -->
    <version.agrona>1.14.0</version.agrona>
    <version.apiguardian>1.1.2</version.apiguardian>
    <version.assertj>3.22.0</version.assertj>
    <version.awaitility>4.1.1</version.awaitility>
    <version.checkstyle>9.2.1</version.checkstyle>
    <version.compress>1.21</version.compress>
    <version.docker-java>3.2.12</version.docker-java>
    <version.duct-tape>1.0.8</version.duct-tape>
    <version.feign>11.7</version.feign>
    <version.jackson>2.13.1</version.jackson>
    <version.junit-jupiter>5.8.2</version.junit-jupiter>
    <version.junit-surefire-provider>1.3.2</version.junit-surefire-provider>
    <version.mockito>4.2.0</version.mockito>
    <version.revapi>0.26.1</version.revapi>
    <version.slf4j>1.7.33</version.slf4j>
    <version.testcontainers>1.16.3</version.testcontainers>
    <version.zeebe>1.3.1</version.zeebe>

    <!-- plugin version -->
    <plugin.version.checkstyle>3.1.2</plugin.version.checkstyle>
    <plugin.version.dependency>3.2.0</plugin.version.dependency>
    <plugin.version.enforcer>3.0.0</plugin.version.enforcer>
    <plugin.version.gpg>3.0.1</plugin.version.gpg>
    <plugin.version.jar>3.2.2</plugin.version.jar>
    <plugin.version.javadoc>3.3.1</plugin.version.javadoc>
    <plugin.version.revapi>0.14.6</plugin.version.revapi>
    <plugin.version.sonar>3.9.0.2155</plugin.version.sonar>
    <plugin.version.spotless>2.20.0</plugin.version.spotless>
    <plugin.version.surefire>3.0.0-M5</plugin.version.surefire>

    <!-- maven extensions -->
    <extension.version.os-maven-plugin>1.6.1</extension.version.os-maven-plugin>
  </properties>

  <dependencyManagement>
    <dependencies>
      <dependency>
        <groupId>io.camunda</groupId>
        <artifactId>zeebe-bom</artifactId>
        <version>${version.zeebe}</version>
        <type>pom</type>
        <scope>import</scope>
      </dependency>

      <dependency>
        <groupId>org.junit</groupId>
        <artifactId>junit-bom</artifactId>
        <version>${version.junit-jupiter}</version>
        <type>pom</type>
        <scope>import</scope>
      </dependency>

      <dependency>
        <groupId>org.testcontainers</groupId>
        <artifactId>testcontainers-bom</artifactId>
        <version>${version.testcontainers}</version>
        <type>pom</type>
        <scope>import</scope>
      </dependency>

      <dependency>
        <groupId>io.github.openfeign</groupId>
        <artifactId>feign-bom</artifactId>
        <version>${version.feign}</version>
        <type>pom</type>
        <scope>import</scope>
      </dependency>
    </dependencies>
  </dependencyManagement>

  <dependencies>
    <dependency>
      <groupId>org.testcontainers</groupId>
      <artifactId>testcontainers</artifactId>
    </dependency>

    <dependency>
      <groupId>org.slf4j</groupId>
      <artifactId>slf4j-api</artifactId>
      <version>${version.slf4j}</version>
    </dependency>

    <dependency>
      <groupId>org.apiguardian</groupId>
      <artifactId>apiguardian-api</artifactId>
      <version>${version.apiguardian}</version>
    </dependency>

    <dependency>
      <groupId>io.camunda</groupId>
      <artifactId>zeebe-client-java</artifactId>
      <scope>provided</scope>
    </dependency>

    <!-- various utilities -->
    <dependency>
      <groupId>org.agrona</groupId>
      <artifactId>agrona</artifactId>
      <version>${version.agrona}</version>
    </dependency>

    <!-- for TAR archives -->
    <dependency>
      <groupId>org.apache.commons</groupId>
      <artifactId>commons-compress</artifactId>
      <version>${version.compress}</version>
    </dependency>

    <!-- for easy actuator clients -->
    <dependency>
      <groupId>io.github.openfeign</groupId>
      <artifactId>feign-core</artifactId>
    </dependency>

    <dependency>
      <groupId>io.github.openfeign</groupId>
      <artifactId>feign-jackson</artifactId>
    </dependency>

    <dependency>
      <groupId>io.github.openfeign</groupId>
      <artifactId>feign-slf4j</artifactId>
    </dependency>

    <!-- required to deserialize the Clock's Instance interface -->
    <dependency>
      <groupId>com.fasterxml.jackson.datatype</groupId>
      <artifactId>jackson-datatype-jsr310</artifactId>
      <version>${version.jackson}</version>
    </dependency>

    <!-- mocking -->
    <dependency>
      <groupId>org.mockito</groupId>
      <artifactId>mockito-core</artifactId>
      <version>${version.mockito}</version>
      <scope>test</scope>
    </dependency>

    <dependency>
      <groupId>org.mockito</groupId>
      <artifactId>mockito-junit-jupiter</artifactId>
      <version>${version.mockito}</version>
      <scope>test</scope>
    </dependency>

    <!-- test engine -->
    <dependency>
      <groupId>org.junit.jupiter</groupId>
      <artifactId>junit-jupiter-api</artifactId>
      <scope>test</scope>
    </dependency>

    <dependency>
      <groupId>org.junit.jupiter</groupId>
      <artifactId>junit-jupiter-params</artifactId>
      <scope>test</scope>
    </dependency>

    <!-- testcontainers junit5 extensions -->
    <dependency>
      <groupId>org.testcontainers</groupId>
      <artifactId>junit-jupiter</artifactId>
      <scope>test</scope>
    </dependency>

    <!-- logging -->
    <dependency>
      <groupId>org.slf4j</groupId>
      <artifactId>slf4j-simple</artifactId>
      <version>${version.slf4j}</version>
      <scope>test</scope>
    </dependency>

    <!-- Zeebe libraries for testing -->
    <dependency>
      <groupId>io.camunda</groupId>
      <artifactId>zeebe-bpmn-model</artifactId>
      <scope>test</scope>
    </dependency>

    <dependency>
      <groupId>io.camunda</groupId>
      <artifactId>zeebe-gateway-protocol-impl</artifactId>
      <scope>test</scope>
    </dependency>

    <!-- assertions -->
    <dependency>
      <groupId>org.assertj</groupId>
      <artifactId>assertj-core</artifactId>
      <version>${version.assertj}</version>
      <scope>test</scope>
    </dependency>

    <dependency>
      <groupId>io.camunda</groupId>
      <artifactId>zeebe-test-util</artifactId>
      <scope>test</scope>
    </dependency>

    <dependency>
      <groupId>org.awaitility</groupId>
      <artifactId>awaitility</artifactId>
      <version>${version.awaitility}</version>
      <scope>test</scope>
    </dependency>
  </dependencies>

  <repositories>
    <repository>
      <releases>
        <enabled>true</enabled>
      </releases>
      <snapshots>
        <enabled>false</enabled>
      </snapshots>
      <id>zeebe</id>
      <name>Zeebe Repository</name>
      <url>https://app.camunda.com/nexus/content/repositories/zeebe-io/</url>
    </repository>

    <repository>
      <releases>
        <enabled>false</enabled>
      </releases>
      <snapshots>
        <enabled>true</enabled>
      </snapshots>
      <id>zeebe-snapshots</id>
      <name>Zeebe Snapshot Repository</name>
      <url>https://app.camunda.com/nexus/content/repositories/zeebe-io-snapshots/</url>
    </repository>
  </repositories>

  <build>
    <plugins>
      <!-- compiler plugin -->
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <configuration combine.children="append">
          <!-- setting it to true unfortunately causes us to recompile every time -->
          <useIncrementalCompilation>false</useIncrementalCompilation>
        </configuration>
      </plugin>

      <!-- JAR packaging plugin -->
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-jar-plugin</artifactId>
        <version>${plugin.version.jar}</version>
        <configuration>
          <useDefaultManifestFile>false</useDefaultManifestFile>
        </configuration>
      </plugin>

      <!-- fix javadoc plugin version to 3.1.0 to fix module error -->
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-javadoc-plugin</artifactId>
        <version>${plugin.version.javadoc}</version>
        <configuration>
          <source>${version.java}</source>
        </configuration>
      </plugin>

      <!-- Licensing and formatting -->
      <plugin>
        <groupId>com.diffplug.spotless</groupId>
        <artifactId>spotless-maven-plugin</artifactId>
        <version>${plugin.version.spotless}</version>
        <configuration>
          <java>
            <googleJavaFormat>
              <version>1.11.0</version>
              <style>GOOGLE</style>
              <reflowLongStrings>true</reflowLongStrings>
            </googleJavaFormat>
            <licenseHeader>
              <file>${project.basedir}/HEADER</file>
            </licenseHeader>
          </java>
          <pom>
            <includes>
              <include>pom.xml</include>
            </includes>
            <sortPom>
              <expandEmptyElements>false</expandEmptyElements>
            </sortPom>
          </pom>
        </configuration>
        <executions>
          <execution>
            <goals>
              <goal>check</goal>
            </goals>
            <phase>validate</phase>
          </execution>
        </executions>
      </plugin>

      <!-- Linting -->
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-checkstyle-plugin</artifactId>
        <version>${plugin.version.checkstyle}</version>
        <configuration>
          <configLocation>check/.checkstyle.xml</configLocation>
          <includeTestSourceDirectory>true</includeTestSourceDirectory>
          <encoding>UTF-8</encoding>
          <failOnViolation>true</failOnViolation>
          <sourceDirectories>
            <sourceDirectory>${project.build.sourceDirectory}</sourceDirectory>
            <sourceDirectory>${project.build.testSourceDirectory}</sourceDirectory>
          </sourceDirectories>
        </configuration>
        <!-- dependency on build tool to reference the checkstyle cfg -->
        <dependencies>
          <dependency>
            <groupId>io.camunda</groupId>
            <artifactId>zeebe-build-tools</artifactId>
            <version>${version.zeebe}</version>
          </dependency>
          <dependency>
            <groupId>com.puppycrawl.tools</groupId>
            <artifactId>checkstyle</artifactId>
            <version>${version.checkstyle}</version>
          </dependency>
        </dependencies>
        <executions>
          <execution>
            <id>validate-java</id>
            <goals>
              <goal>check</goal>
            </goals>
            <phase>validate</phase>
            <configuration/>
          </execution>
        </executions>
      </plugin>

      <!-- unit tests -->
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <version>${plugin.version.surefire}</version>
        <configuration>
          <failIfNoTests>false</failIfNoTests>
          <trimStackTrace>false</trimStackTrace>
          <redirectTestOutputToFile>true</redirectTestOutputToFile>
        </configuration>
        <dependencies>
          <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-engine</artifactId>
            <version>${version.junit-jupiter}</version>
          </dependency>
        </dependencies>
      </plugin>

      <!-- compatibility checks/guard -->
      <plugin>
        <groupId>org.revapi</groupId>
        <artifactId>revapi-maven-plugin</artifactId>
        <version>${plugin.version.revapi}</version>
        <configuration>
          <checkDependencies>false</checkDependencies>
          <expandProperties>true</expandProperties>
          <analysisConfigurationFiles>
            <configurationFile>
              <path>revapi.json</path>
            </configurationFile>
          </analysisConfigurationFiles>
          <oldVersion>RELEASE</oldVersion>
        </configuration>
        <dependencies>
          <dependency>
            <groupId>org.revapi</groupId>
            <artifactId>revapi-java</artifactId>
            <version>${version.revapi}</version>
          </dependency>
        </dependencies>
        <executions>
          <execution>
            <id>check</id>
            <goals>
              <goal>check</goal>
            </goals>
            <phase>verify</phase>
          </execution>
        </executions>
      </plugin>

      <!-- dependency rules enforcement -->
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-enforcer-plugin</artifactId>
        <version>${plugin.version.enforcer}</version>
        <executions>
          <execution>
            <id>enforce-unique-dependencies</id>
            <goals>
              <goal>enforce</goal>
            </goals>
            <configuration>
              <rules>
                <banDuplicatePomDependencyVersions/>
              </rules>
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>

  <profiles>
    <profile>
      <id>community-action-maven-release</id>
      <properties>
        <skipChecks>true</skipChecks>
        <skipTests>true</skipTests>
      </properties>
      <build>
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-gpg-plugin</artifactId>
            <version>${plugin.version.gpg}</version>
            <configuration>
              <!-- Prevent gpg from using pinentry programs -->
              <gpgArguments>
                <arg>--pinentry-mode</arg>
                <arg>loopback</arg>
              </gpgArguments>
            </configuration>
            <executions>
              <execution>
                <id>sign-artifacts</id>
                <goals>
                  <goal>sign</goal>
                </goals>
                <phase>verify</phase>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>

    <profile>
      <id>parallel-tests</id>
      <properties>
        <forkCount>0.5C</forkCount>
      </properties>
      <build>
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <configuration>
              <forkCount>${forkCount}</forkCount>
              <reuseForks>true</reuseForks>
            </configuration>
          </plugin>
        </plugins>
      </build>
    </profile>
  </profiles>
</project>
