<?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>
  <name>Zeebe Protocol Immutables</name>
  <artifactId>zeebe-protocol-immutables</artifactId>
  <groupId>io.zeebe</groupId>
  <packaging>jar</packaging>
  <version>2.0.0</version>
  <inceptionYear>2020</inceptionYear>
  <url>https://github.com/zeebe-io/zeebe-protocol-immutables</url>

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

  <properties>
    <!-- release parent settings -->
    <version.java>11</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>

    <!-- license header -->
    <license.header>com/mycila/maven/plugin/license/templates/APACHE-2.txt</license.header>

    <!-- skip checks -->
    <skip.check>false</skip.check>

    <!-- project dependencies -->
    <version.assertj>3.19.0</version.assertj>
    <version.awaitility>4.1.0</version.awaitility>
    <version.checkstyle>8.42</version.checkstyle>
    <version.immutables>2.8.9-ea-1</version.immutables>
    <version.jackson>2.12.3</version.jackson>
    <version.javax-annotation>1.3.2</version.javax-annotation>
    <version.junit>5.7.1</version.junit>
    <version.revapi>0.24.1</version.revapi>
    <version.slf4j>1.7.30</version.slf4j>
    <version.zeebe>1.0.0</version.zeebe>

    <!-- plugin version -->
    <plugin.version.checkstyle>3.1.2</plugin.version.checkstyle>
    <plugin.version.enforcer>3.0.0-M2</plugin.version.enforcer>
    <plugin.version.fmt>2.10</plugin.version.fmt>
    <plugin.version.gpg>3.0.1</plugin.version.gpg>
    <plugin.version.javadoc>3.2.0</plugin.version.javadoc>
    <plugin.version.license>4.1</plugin.version.license>
    <plugin.version.owasp>6.1.6</plugin.version.owasp>
    <plugin.version.revapi>0.14.2</plugin.version.revapi>
    <plugin.version.sonar>3.9.0.2155</plugin.version.sonar>
    <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>
        <scope>import</scope>
        <type>pom</type>
      </dependency>
    </dependencies>
  </dependencyManagement>

  <dependencies>
    <dependency>
      <groupId>io.camunda</groupId>
      <artifactId>zeebe-protocol</artifactId>
    </dependency>

    <dependency>
      <groupId>com.fasterxml.jackson.core</groupId>
      <artifactId>jackson-databind</artifactId>
      <version>${version.jackson}</version>
    </dependency>

    <dependency>
      <groupId>org.immutables</groupId>
      <artifactId>value</artifactId>
      <version>${version.immutables}</version>
      <scope>provided</scope>
    </dependency>

    <dependency>
      <groupId>javax.annotation</groupId>
      <artifactId>javax.annotation-api</artifactId>
      <version>${version.javax-annotation}</version>
      <scope>provided</scope>
    </dependency>

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

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

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

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

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

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

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

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

  <build>
    <plugins>
      <!-- JAVADOC -->
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-javadoc-plugin</artifactId>
        <configuration>
          <sourcepath>
            ${project.build.sourceDirectory}:${project.build.directory}/generated-sources/annotations
          </sourcepath>
        </configuration>
      </plugin>

      <!-- LICENSE PLUGIN -->
      <plugin>
        <groupId>com.mycila</groupId>
        <artifactId>license-maven-plugin</artifactId>
        <version>${plugin.version.license}</version>
        <configuration>
          <header>${license.header}</header>
          <properties>
            <owner>camunda services GmbH</owner>
            <email>info@camunda.com</email>
          </properties>
          <includes>
            <include>**/*.java</include>
          </includes>
          <mapping>
            <java>SLASHSTAR_STYLE</java>
          </mapping>
          <skip>${skip.check}</skip>
        </configuration>
        <executions>
          <execution>
            <id>add-license</id>
            <phase>compile</phase>
            <goals>
              <goal>format</goal>
            </goals>
          </execution>
        </executions>
      </plugin>

      <!-- CHECKSTYLE -->
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-checkstyle-plugin</artifactId>
        <version>${plugin.version.checkstyle}</version>
        <!-- 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>
        <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>
          <skip>${skip.check}</skip>
        </configuration>
        <executions>
          <execution>
            <id>validate-java</id>
            <phase>validate</phase>
            <goals>
              <goal>check</goal>
            </goals>
            <configuration>
            </configuration>
          </execution>
        </executions>
      </plugin>

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

      <!-- Google code format plugin -->
      <plugin>
        <groupId>com.coveo</groupId>
        <artifactId>fmt-maven-plugin</artifactId>
        <version>${plugin.version.fmt}</version>
        <executions>
          <execution>
            <goals>
              <goal>format</goal>
            </goals>
          </execution>
        </executions>
        <configuration>
          <skip>${skip.check}</skip>
        </configuration>
      </plugin>

      <!-- vulnerability scanning -->
      <plugin>
        <groupId>org.owasp</groupId>
        <artifactId>dependency-check-maven</artifactId>
        <version>${plugin.version.owasp}</version>
        <configuration>
          <skipProvidedScope>true</skipProvidedScope>
          <skipRuntimeScope>true</skipRuntimeScope>
          <failBuildOnCVSS>7</failBuildOnCVSS>
          <assemblyAnalyzerEnabled>false</assemblyAnalyzerEnabled>
          <format>JSON</format>
          <prettyPrint>true</prettyPrint>
          <skip>${skip.check}</skip>
        </configuration>
        <executions>
          <execution>
            <phase>verify</phase>
            <goals>
              <goal>check</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>

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

    <profile>
      <id>sonar</id>
      <properties>
        <!-- sonarscanner integration -->
        <!-- sonar.login token must be passed at runtime to avoid sharing token -->
        <sonar.host.url>https://sonarcloud.io</sonar.host.url>
        <sonar.organization>zeebe-io</sonar.organization>
        <sonar.login>${env.SONARCLOUD_TOKEN}</sonar.login>

        <!-- skip some checks -->
        <skipTests>true</skipTests>
        <skip.check>true</skip.check>
      </properties>
      <build>
        <plugins>
          <plugin>
            <groupId>org.sonarsource.scanner.maven</groupId>
            <artifactId>sonar-maven-plugin</artifactId>
            <version>${plugin.version.sonar}</version>
            <executions>
              <execution>
                <phase>verify</phase>
                <goals>
                  <goal>sonar</goal>
                </goals>
              </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>

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

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

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