<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 Parent</name>
  <artifactId>zb-parent</artifactId>
  <version>0.14.0</version>
  <packaging>pom</packaging>
  <inceptionYear>2017</inceptionYear>
  <url>http://zeebe.io/</url>

  <parent>
    <groupId>io.zeebe</groupId>
    <artifactId>zb-bom</artifactId>
    <version>0.14.0</version>
    <relativePath>../bom</relativePath>
  </parent>

  <properties>
    <project.build.sourceEncoding>utf-8</project.build.sourceEncoding>
    <license.header>com/mycila/maven/plugin/license/templates/APACHE-2.txt</license.header>
    <!-- disable jdk8 javadoc checks on release build -->
    <additionalparam>-Xdoclint:none</additionalparam>
    <checkstyle.config.location>.checkstyle.xml</checkstyle.config.location>

    <!-- EXTERNAL LIBS -->
    <version.agrona>0.9.27</version.agrona>
    <version.assertj>3.11.1</version.assertj>
    <version.elasticsearch>6.5.1</version.elasticsearch>
    <version.grpc>1.16.1</version.grpc>
    <version.hamcrest>1.3</version.hamcrest>
    <version.jackson>2.9.7</version.jackson>
    <version.jmh>1.21</version.jmh>
    <version.junit>4.12</version.junit>
    <version.log4j>2.11.1</version.log4j>
    <version.mockito>2.23.4</version.mockito>
    <version.model>7.7.0</version.model>
    <version.msgpack>0.8.16</version.msgpack>
    <version.netty.tcnative>2.0.20.Final</version.netty.tcnative>
    <version.protobuf>3.6.1</version.protobuf>
    <version.protoc>3.6.0</version.protoc>
    <version.rocksdbjni>5.17.2</version.rocksdbjni>
    <version.sbe>1.10.0</version.sbe>
    <version.scala-parser>1.0.6</version.scala-parser>
    <version.scala>2.12.2</version.scala>
    <version.slf4j>1.7.25</version.slf4j>
    <version.streamex>0.6.7</version.streamex>
    <version.toml>0.7.2</version.toml>

    <!-- maven plugins -->
    <plugin.version.antrun>1.8</plugin.version.antrun>
    <plugin.version.appassembler>2.0.0</plugin.version.appassembler>
    <plugin.version.build-helper>3.0.0</plugin.version.build-helper>
    <plugin.version.checkstyle>3.0.0</plugin.version.checkstyle>
    <plugin.version.compiler>3.8.0</plugin.version.compiler>
    <plugin.version.elasticsearch>6.8</plugin.version.elasticsearch>
    <plugin.version.exec>1.6.0</plugin.version.exec>
    <plugin.version.failsafe>2.22.1</plugin.version.failsafe>
    <plugin.version.fmt>2.6.0</plugin.version.fmt>
    <plugin.version.license>3.0</plugin.version.license>
    <plugin.version.protobuf-maven-plugin>0.6.1</plugin.version.protobuf-maven-plugin>
    <plugin.version.replacer>1.5.3</plugin.version.replacer>
    <plugin.version.resources>3.1.0</plugin.version.resources>
    <plugin.version.scala>3.2.1</plugin.version.scala>
    <plugin.version.shade>3.2.1</plugin.version.shade>
    <plugin.version.surefire>2.22.1</plugin.version.surefire>
    <plugin.version.versions>2.7</plugin.version.versions>

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

  <dependencyManagement>
    <dependencies>
      <dependency>
        <groupId>io.zeebe</groupId>
        <artifactId>zeebe-broker-core</artifactId>
        <version>${project.version}</version>
        <classifier>tests</classifier>
        <type>test-jar</type>
      </dependency>

      <dependency>
        <groupId>org.agrona</groupId>
        <artifactId>agrona</artifactId>
        <version>${version.agrona}</version>
      </dependency>

      <dependency>
        <groupId>com.fasterxml.jackson</groupId>
        <artifactId>jackson-bom</artifactId>
        <version>${version.jackson}</version>
        <scope>import</scope>
        <type>pom</type>
      </dependency>

      <dependency>
        <groupId>org.msgpack</groupId>
        <artifactId>msgpack-core</artifactId>
        <version>${version.msgpack}</version>
      </dependency>

      <dependency>
        <groupId>org.msgpack</groupId>
        <artifactId>jackson-dataformat-msgpack</artifactId>
        <version>${version.msgpack}</version>
      </dependency>

      <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>${version.junit}</version>
      </dependency>

      <dependency>
        <groupId>org.mockito</groupId>
        <artifactId>mockito-core</artifactId>
        <version>${version.mockito}</version>
      </dependency>

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

      <dependency>
        <groupId>org.openjdk.jmh</groupId>
        <artifactId>jmh-core</artifactId>
        <version>${version.jmh}</version>
      </dependency>

      <dependency>
        <groupId>org.openjdk.jmh</groupId>
        <artifactId>jmh-generator-annprocess</artifactId>
        <version>${version.jmh}</version>
      </dependency>

      <dependency>
        <groupId>com.moandjiezana.toml</groupId>
        <artifactId>toml4j</artifactId>
        <version>${version.toml}</version>
      </dependency>

      <dependency>
        <groupId>uk.co.real-logic</groupId>
        <artifactId>sbe-tool</artifactId>
        <version>${version.sbe}</version>
      </dependency>

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

      <dependency>
        <groupId>org.apache.logging.log4j</groupId>
        <artifactId>log4j-slf4j-impl</artifactId>
        <version>${version.log4j}</version>
      </dependency>

      <dependency>
        <groupId>org.apache.logging.log4j</groupId>
        <artifactId>log4j-core</artifactId>
        <version>${version.log4j}</version>
      </dependency>

      <dependency>
        <groupId>org.hamcrest</groupId>
        <artifactId>hamcrest-library</artifactId>
        <version>${version.hamcrest}</version>
      </dependency>

      <dependency>
        <groupId>org.scala-lang.modules</groupId>
        <artifactId>scala-parser-combinators_2.12</artifactId>
        <version>${version.scala-parser}</version>
      </dependency>

      <dependency>
        <groupId>org.rocksdb</groupId>
        <artifactId>rocksdbjni</artifactId>
        <version>${version.rocksdbjni}</version>
      </dependency>

      <dependency>
        <groupId>io.grpc</groupId>
        <artifactId>grpc-protobuf</artifactId>
        <version>${version.grpc}</version>
      </dependency>

      <dependency>
        <groupId>io.grpc</groupId>
        <artifactId>grpc-stub</artifactId>
        <version>${version.grpc}</version>
      </dependency>

      <dependency>
        <groupId>com.google.protobuf</groupId>
        <artifactId>protobuf-java-util</artifactId>
        <version>${version.protobuf}</version>
      </dependency>

      <dependency>
        <groupId>io.netty</groupId>
        <artifactId>netty-tcnative-boringssl-static</artifactId>
        <version>${version.netty.tcnative}</version>
      </dependency>

      <dependency>
        <groupId>io.grpc</groupId>
        <artifactId>grpc-netty</artifactId>
        <version>${version.grpc}</version>
      </dependency>

      <dependency>
        <groupId>io.grpc</groupId>
        <artifactId>grpc-testing</artifactId>
        <version>${version.grpc}</version>
      </dependency>

      <dependency>
        <groupId>one.util</groupId>
        <artifactId>streamex</artifactId>
        <version>${version.streamex}</version>
      </dependency>

      <dependency>
        <groupId>org.elasticsearch.client</groupId>
        <artifactId>elasticsearch-rest-high-level-client</artifactId>
        <version>${version.elasticsearch}</version>
      </dependency>

    </dependencies>
  </dependencyManagement>

  <build>
    <pluginManagement>
      <plugins>
        <!-- MAVEN COMPILER -->
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-compiler-plugin</artifactId>
          <version>${plugin.version.compiler}</version>
          <configuration>
            <source>1.8</source>
            <target>1.8</target>
          </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>
              <include>**/*.scala</include>
            </includes>
            <mapping>
              <java>SLASHSTAR_STYLE</java>
            </mapping>
          </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.zeebe</groupId>
              <artifactId>zb-build-tools</artifactId>
              <version>${project.version}</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>
              <sourceDirectory>${project.basedir}/src/test/jmh</sourceDirectory>
            </sourceDirectories>
          </configuration>
          <executions>
            <execution>
              <id>validate-java</id>
              <phase>validate</phase>
              <goals>
                <goal>check</goal>
              </goals>
              <configuration>
              </configuration>
            </execution>
          </executions>
        </plugin>

        <!-- MAVEN SUREFIRE -->
        <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>
            <properties>
              <property>
                <name>listener</name>
                <value>io.zeebe.ZeebeTestListener</value>
              </property>
            </properties>
          </configuration>
        </plugin>

        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-failsafe-plugin</artifactId>
          <version>${plugin.version.failsafe}</version>
          <executions>
            <execution>
              <goals>
                <goal>integration-test</goal>
                <goal>verify</goal>
              </goals>
            </execution>
          </executions>
          <configuration>
            <failIfNoTests>false</failIfNoTests>
            <trimStackTrace>false</trimStackTrace>
            <redirectTestOutputToFile>true</redirectTestOutputToFile>
            <properties>
              <property>
                <name>listener</name>
                <value>io.zeebe.ZeebeTestListener</value>
              </property>
            </properties>
          </configuration>
        </plugin>

        <!-- Build Helper Plugin -->
        <plugin>
          <groupId>org.codehaus.mojo</groupId>
          <artifactId>build-helper-maven-plugin</artifactId>
          <version>${plugin.version.build-helper}</version>
        </plugin>

        <!-- Shade Plugin -->
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-shade-plugin</artifactId>
          <version>${plugin.version.shade}</version>
        </plugin>

        <!-- App Assembler Plugin -->
        <plugin>
          <groupId>org.codehaus.mojo</groupId>
          <artifactId>appassembler-maven-plugin</artifactId>
          <version>${plugin.version.appassembler}</version>
        </plugin>

        <!-- Exec Plugin -->
        <plugin>
          <groupId>org.codehaus.mojo</groupId>
          <artifactId>exec-maven-plugin</artifactId>
          <version>${plugin.version.exec}</version>
          <configuration>
            <!-- Define system properties in one place, see https://github.com/camunda-zeebe/zeebe/issues/377 -->
            <systemProperties>
              <systemProperty>
                <key>sbe.output.dir</key>
                <value>${project.build.directory}/generated-sources/sbe</value>
              </systemProperty>
              <systemProperty>
                <key>sbe.java.generate.interfaces</key>
                <value>true</value>
              </systemProperty>
              <systemProperty>
                <key>sbe.decode.unknown.enum.values</key>
                <value>true</value>
              </systemProperty>
            </systemProperties>
          </configuration>
        </plugin>

        <!-- Resources Plugin -->
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-resources-plugin</artifactId>
          <version>${plugin.version.resources}</version>
        </plugin>

        <!-- Scala Plugin -->
        <plugin>
          <groupId>net.alchim31.maven</groupId>
          <artifactId>scala-maven-plugin</artifactId>
          <version>${plugin.version.scala}</version>
          <executions>
            <execution>
              <id>scala-compile-first</id>
              <phase>process-resources</phase>
              <goals>
                <goal>add-source</goal>
                <goal>compile</goal>
              </goals>
            </execution>
            <execution>
              <id>scala-test-compile</id>
              <phase>process-test-resources</phase>
              <goals>
                <goal>testCompile</goal>
              </goals>
            </execution>
          </executions>
          <configuration>
            <scalaVersion>${version.scala}</scalaVersion>
          </configuration>
        </plugin>

        <!--This plugin's configuration is used to store Eclipse m2e settings
          only. It has no influence on the Maven build itself. -->
        <plugin>
          <groupId>org.eclipse.m2e</groupId>
          <artifactId>lifecycle-mapping</artifactId>
          <version>1.0.0</version>
          <configuration>
            <lifecycleMappingMetadata>
              <pluginExecutions>
                <pluginExecution>
                  <pluginExecutionFilter>
                    <groupId>org.codehaus.mojo</groupId>
                    <artifactId>exec-maven-plugin</artifactId>
                    <versionRange>[1.3.2,)</versionRange>
                    <goals>
                      <goal>java</goal>
                    </goals>
                  </pluginExecutionFilter>
                  <action>
                    <ignore />
                  </action>
                </pluginExecution>
              </pluginExecutions>
            </lifecycleMappingMetadata>
          </configuration>
        </plugin>

        <!-- Ant run plugin -->
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-antrun-plugin</artifactId>
          <version>${plugin.version.antrun}</version>
        </plugin>

        <!-- Versions plugin to update versions in pom files -->
        <plugin>
          <groupId>org.codehaus.mojo</groupId>
          <artifactId>versions-maven-plugin</artifactId>
          <version>${plugin.version.versions}</version>
        </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>
            <additionalSourceDirectories>
              <additionalSourceDirectory>${project.basedir}/src/test/jmh</additionalSourceDirectory>
            </additionalSourceDirectories>
          </configuration>
        </plugin>

        <plugin>
          <groupId>org.xolstice.maven.plugins</groupId>
          <artifactId>protobuf-maven-plugin</artifactId>
          <version>${plugin.version.protobuf-maven-plugin}</version>
          <configuration>
            <protocArtifact>
              com.google.protobuf:protoc:${version.protoc}:exe:${os.detected.classifier}
            </protocArtifact>
            <pluginId>grpc-java</pluginId>
            <pluginArtifact>
              io.grpc:protoc-gen-grpc-java:${version.grpc}:exe:${os.detected.classifier}
            </pluginArtifact>
          </configuration>
          <executions>
            <execution>
              <goals>
                <goal>compile</goal>
                <goal>compile-custom</goal>
              </goals>
            </execution>
          </executions>
        </plugin>

        <plugin>
          <groupId>com.google.code.maven-replacer-plugin</groupId>
          <artifactId>replacer</artifactId>
          <version>${plugin.version.replacer}</version>
        </plugin>

        <plugin>
          <groupId>com.github.alexcojocaru</groupId>
          <artifactId>elasticsearch-maven-plugin</artifactId>
          <version>${plugin.version.elasticsearch}</version>
          <configuration>
            <version>${version.elasticsearch}</version>
            <skip>${skipTests}</skip>
          </configuration>
          <executions>
            <execution>
              <id>start-elasticsearch</id>
              <phase>pre-integration-test</phase>
              <goals>
                <goal>runforked</goal>
              </goals>
            </execution>
            <execution>
              <id>stop-elasticsearch</id>
              <phase>post-integration-test</phase>
              <goals>
                <goal>stop</goal>
              </goals>
            </execution>
          </executions>
        </plugin>

      </plugins>

    </pluginManagement>

    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
      </plugin>

      <plugin>
        <groupId>com.mycila</groupId>
        <artifactId>license-maven-plugin</artifactId>
      </plugin>

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-checkstyle-plugin</artifactId>
      </plugin>

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
      </plugin>

      <plugin>
        <groupId>com.coveo</groupId>
        <artifactId>fmt-maven-plugin</artifactId>
      </plugin>

      <!-- add jmh test sources to build -->
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>build-helper-maven-plugin</artifactId>
        <executions>
          <execution>
            <id>add-jmh-tests</id>
            <phase>generate-test-sources</phase>
            <goals>
              <goal>add-test-source</goal>
            </goals>
            <configuration>
              <sources>
                <source>src/test/jmh</source>
              </sources>
            </configuration>
          </execution>
        </executions>
      </plugin>

    </plugins>
  </build>

  <dependencies>
    <dependency>
      <groupId>io.zeebe</groupId>
      <artifactId>zb-build-tools</artifactId>
      <scope>test</scope>
    </dependency>
  </dependencies>

  <profiles>
    <profile>
      <id>skip-unstable-tests</id>
      <build>
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <configuration>
              <excludedGroups>io.zeebe.UnstableTest</excludedGroups>
            </configuration>
          </plugin>
        </plugins>
      </build>
    </profile>
    <profile>
      <id>skip-unstable-ci</id>
      <build>
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <configuration>
              <excludedGroups>io.zeebe.UnstableCI</excludedGroups>
            </configuration>
          </plugin>
        </plugins>
      </build>
    </profile>
    <profile>
      <id>retry-tests</id>
      <build>
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <configuration>
              <rerunFailingTestsCount>3</rerunFailingTestsCount>
            </configuration>
          </plugin>
        </plugins>
      </build>
    </profile>
    <profile>
      <id>parallel-tests</id>
      <build>
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <configuration>
              <forkCount>0.5C</forkCount>
              <reuseForks>true</reuseForks>
              <systemPropertyVariables>
                <!-- use two dollar signs to prevent maven properties resolution, surefire will resolve
                the property later. If only ${surefire.forkNumber} is used maven will fail to resolve it
                and don't set the system property -->
                <testForkNumber>$${surefire.forkNumber}</testForkNumber>
              </systemPropertyVariables>
            </configuration>
          </plugin>
        </plugins>
      </build>
    </profile>
  </profiles>
</project>
