<?xml version="1.0" encoding="UTF-8"?>
<!--

    Copyright 2016-2019 The OpenZipkin Authors

    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.

-->
<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>io.zipkin.dependencies</groupId>
  <artifactId>zipkin-dependencies-parent</artifactId>
  <version>2.4.1</version>
  <packaging>pom</packaging>

  <modules>
    <module>cassandra</module>
    <module>cassandra3</module>
    <module>mysql</module>
    <module>elasticsearch</module>
    <module>main</module>
  </modules>

  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <project.build.resourceEncoding>UTF-8</project.build.resourceEncoding>

    <main.basedir>${project.basedir}</main.basedir>

    <!-- override to set exclusions per-project -->
    <errorprone.args />
    <errorprone.version>2.3.3</errorprone.version>

    <!-- can't switch to 2.12 until spark-cassandra-connector updates -->
    <scala.binary.version>2.11</scala.binary.version>
    <spark.version>2.4.4</spark.version>

    <zipkin.version>2.18.0</zipkin.version>
    <armeria.version>0.94.0</armeria.version>

    <junit.version>4.12</junit.version>
    <junit.jupiter.version>5.5.2</junit.jupiter.version>

    <assertj.version>3.13.2</assertj.version>
    <jackson.version>2.9.9.20190807</jackson.version>
    <!-- connector uses an old version of the driver -->
    <cassandra-driver-core.version>3.7.2</cassandra-driver-core.version>
    <spark-cassandra-connector.version>2.4.1</spark-cassandra-connector.version>
    <testcontainers.version>1.12.2</testcontainers.version>

    <maven-compiler-plugin.version>3.8.1</maven-compiler-plugin.version>
    <maven-install-plugin.version>3.0.0-M1</maven-install-plugin.version>
    <maven-deploy-plugin.version>3.0.0-M1</maven-deploy-plugin.version>
    <maven-source-plugin.version>3.1.0</maven-source-plugin.version>
    <maven-javadoc-plugin.version>3.1.1</maven-javadoc-plugin.version>
    <license-maven-plugin.version>3.0</license-maven-plugin.version>
    <maven-jar-plugin.version>3.1.2</maven-jar-plugin.version>
    <maven-release-plugin.version>2.5.3</maven-release-plugin.version>
    <maven-shade-plugin.version>3.2.1</maven-shade-plugin.version>
    <maven-failsafe-plugin.version>3.0.0-M3</maven-failsafe-plugin.version>
  </properties>

  <name>Zipkin Dependencies (Parent)</name>
  <description>Zipkin Dependencies (Parent)</description>
  <url>https://github.com/openzipkin/zipkin-dependencies</url>
  <inceptionYear>2016</inceptionYear>

  <organization>
    <name>OpenZipkin</name>
    <url>https://zipkin.io/</url>
  </organization>

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

  <scm>
    <url>https://github.com/openzipkin/zipkin-dependencies</url>
    <connection>scm:git:https://github.com/openzipkin/zipkin-dependencies.git</connection>
    <developerConnection>scm:git:https://github.com/openzipkin/zipkin-dependencies.git</developerConnection>
    <tag>2.4.1</tag>
  </scm>

  <!-- Developer section is needed for Maven Central, but doesn't need to include each person -->
  <developers>
    <developer>
      <id>openzipkin</id>
      <name>OpenZipkin Gitter</name>
      <url>https://gitter.im/openzipkin/zipkin</url>
    </developer>
  </developers>

  <distributionManagement>
    <repository>
      <id>bintray</id>
      <url>https://api.bintray.com/maven/openzipkin/maven/zipkin-dependencies/;publish=1</url>
    </repository>
    <snapshotRepository>
      <id>jfrog-snapshots</id>
      <url>https://oss.jfrog.org/artifactory/oss-snapshot-local</url>
    </snapshotRepository>
  </distributionManagement>

  <issueManagement>
    <system>Github</system>
    <url>https://github.com/openzipkin/zipkin-dependencies/issues</url>
  </issueManagement>

  <dependencyManagement>
    <dependencies>
      <dependency>
        <groupId>io.zipkin.zipkin2</groupId>
        <artifactId>zipkin-tests</artifactId>
        <version>${zipkin.version}</version>
      </dependency>

      <dependency>
        <groupId>${project.groupId}</groupId>
        <artifactId>zipkin-dependencies-cassandra</artifactId>
        <version>${project.version}</version>
      </dependency>

      <dependency>
        <groupId>${project.groupId}</groupId>
        <artifactId>zipkin-dependencies-cassandra3</artifactId>
        <version>${project.version}</version>
      </dependency>

      <dependency>
        <groupId>com.datastax.cassandra</groupId>
        <artifactId>cassandra-driver-core</artifactId>
        <version>${cassandra-driver-core.version}</version>
      </dependency>

      <dependency>
        <groupId>com.datastax.cassandra</groupId>
        <artifactId>cassandra-driver-mapping</artifactId>
        <version>${cassandra-driver-core.version}</version>
      </dependency>

      <dependency>
        <groupId>${project.groupId}</groupId>
        <artifactId>zipkin-dependencies-mysql</artifactId>
        <version>${project.version}</version>
      </dependency>

      <dependency>
        <groupId>${project.groupId}</groupId>
        <artifactId>zipkin-dependencies-elasticsearch</artifactId>
        <version>${project.version}</version>
      </dependency>

      <dependency>
        <groupId>org.apache.spark</groupId>
        <artifactId>spark-core_${scala.binary.version}</artifactId>
        <version>${spark.version}</version>
      </dependency>

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

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

  <dependencies>
    <dependency>
      <groupId>org.apache.spark</groupId>
      <artifactId>spark-core_${scala.binary.version}</artifactId>
    </dependency>
    <dependency>
      <groupId>io.zipkin.zipkin2</groupId>
      <artifactId>zipkin</artifactId>
      <version>${zipkin.version}</version>
    </dependency>

    <!-- avoids compile error: Could not access type DataFrame in package org.apache.spark.sql -->
    <dependency>
      <groupId>org.apache.spark</groupId>
      <artifactId>spark-sql_${scala.binary.version}</artifactId>
      <version>${spark.version}</version>
    </dependency>

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

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

    <dependency>
      <groupId>org.junit.vintage</groupId>
      <artifactId>junit-vintage-engine</artifactId>
      <version>${junit.jupiter.version}</version>
    </dependency>

    <!--
    Current versions of JUnit5 provide the above junit-jupiter artifact for convenience but we may
    still have transitive dependencies on these older artifacts and have to make sure they're all
    using the same version.
    -->
    <dependency>
      <groupId>org.junit.jupiter</groupId>
      <artifactId>junit-jupiter-api</artifactId>
      <version>${junit.jupiter.version}</version>
    </dependency>

    <dependency>
      <groupId>org.junit.jupiter</groupId>
      <artifactId>junit-jupiter-engine</artifactId>
      <version>${junit.jupiter.version}</version>
    </dependency>

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

  <build>
    <pluginManagement>
      <plugins>
        <!-- mvn -N io.takari:maven:wrapper generates the ./mvnw script -->
        <plugin>
          <groupId>io.takari</groupId>
          <artifactId>maven</artifactId>
          <version>0.7.6</version>
          <configuration>
            <maven>3.6.2</maven>
          </configuration>
        </plugin>

        <plugin>
          <artifactId>maven-compiler-plugin</artifactId>
          <version>${maven-compiler-plugin.version}</version>
          <inherited>true</inherited>
          <configuration>
            <source>1.8</source>
            <target>1.8</target>
            <!-- or die! com.sun.tools.javac.api.JavacTool -->
            <fork>true</fork>
            <showWarnings>true</showWarnings>
          </configuration>
        </plugin>

        <plugin>
          <artifactId>maven-jar-plugin</artifactId>
          <version>${maven-jar-plugin.version}</version>
        </plugin>

        <plugin>
          <artifactId>maven-shade-plugin</artifactId>
          <version>${maven-shade-plugin.version}</version>
        </plugin>
      </plugins>
    </pluginManagement>

    <plugins>
      <plugin>
        <artifactId>maven-surefire-plugin</artifactId>
        <version>${maven-failsafe-plugin.version}</version>
      </plugin>

      <plugin>
        <artifactId>maven-failsafe-plugin</artifactId>
        <version>${maven-failsafe-plugin.version}</version>
        <executions>
          <execution>
            <id>integration-test</id>
            <goals>
              <goal>integration-test</goal>
            </goals>
          </execution>
          <execution>
            <id>verify</id>
            <goals>
              <goal>verify</goal>
            </goals>
          </execution>
        </executions>
      </plugin>

      <plugin>
        <artifactId>maven-install-plugin</artifactId>
        <version>${maven-install-plugin.version}</version>
      </plugin>

      <!-- Uploads occur as a last step (which also adds checksums) -->
      <plugin>
        <artifactId>maven-deploy-plugin</artifactId>
        <version>${maven-deploy-plugin.version}</version>
      </plugin>

      <plugin>
        <groupId>com.mycila</groupId>
        <artifactId>license-maven-plugin</artifactId>
        <version>${license-maven-plugin.version}</version>
        <configuration>
          <!-- session.executionRootDirectory resolves properly even with nested modules -->
          <header>${main.basedir}/src/etc/header.txt</header>
          <mapping>
            <!-- Don't use javadoc style as this makes code formatters break it by adding tags! -->
            <java>SLASHSTAR_STYLE</java>
          </mapping>
          <excludes>
            <exclude>.travis.yml</exclude>
            <exclude>.editorconfig</exclude>
            <exclude>.gitattributes</exclude>
            <exclude>.gitignore</exclude>
            <exclude>.mvn/**</exclude>
            <exclude>mvnw*</exclude>
            <exclude>etc/header.txt</exclude>
            <exclude>**/.idea/**</exclude>
            <exclude>LICENSE</exclude>
            <exclude>**/*.md</exclude>
            <exclude>**/nohup.out</exclude>
            <exclude>src/test/resources/**</exclude>
            <exclude>src/main/resources/**</exclude>
            <exclude>docker/periodic/**</exclude>
          </excludes>
          <strictCheck>true</strictCheck>
        </configuration>
        <dependencies>
          <dependency>
            <groupId>com.mycila</groupId>
            <artifactId>license-maven-plugin-git</artifactId>
            <version>${license-maven-plugin.version}</version>
          </dependency>
        </dependencies>
        <executions>
          <execution>
            <goals>
              <goal>check</goal>
            </goals>
            <phase>compile</phase>
          </execution>
        </executions>
      </plugin>

      <plugin>
        <artifactId>maven-release-plugin</artifactId>
        <version>${maven-release-plugin.version}</version>
        <configuration>
          <useReleaseProfile>false</useReleaseProfile>
          <releaseProfiles>release</releaseProfiles>
          <autoVersionSubmodules>true</autoVersionSubmodules>
          <tagNameFormat>@{project.version}</tagNameFormat>
        </configuration>
      </plugin>

      <plugin>
        <groupId>io.zipkin.centralsync-maven-plugin</groupId>
        <artifactId>centralsync-maven-plugin</artifactId>
        <version>0.1.1</version>
        <configuration>
          <packageName>zipkin-dependencies</packageName>
        </configuration>
      </plugin>

      <plugin>
        <artifactId>maven-enforcer-plugin</artifactId>
        <version>3.0.0-M2</version>
        <executions>
          <execution>
            <id>enforce-java</id>
            <goals>
              <goal>enforce</goal>
            </goals>
            <configuration>
              <rules>
                <!-- Spark doesn't support Java 9+, yet https://issues.apache.org/jira/browse/SPARK-24421 -->
                <requireJavaVersion>
                  <version>[1.8,9)</version>
                </requireJavaVersion>
              </rules>
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>

  <profiles>
    <profile>
      <id>error-prone-1.8</id>
      <activation>
        <jdk>1.8</jdk>
        <activeByDefault>false</activeByDefault>
      </activation>
      <build>
        <plugins>
          <plugin>
            <artifactId>maven-compiler-plugin</artifactId>
            <executions>
              <execution>
                <!-- only use errorprone on main source tree -->
                <id>default-compile</id>
                <phase>compile</phase>
                <goals>
                  <goal>compile</goal>
                </goals>
                <configuration>
                  <compilerId>javac-with-errorprone</compilerId>
                  <forceJavacCompilerUse>true</forceJavacCompilerUse>
                  <compilerArgs>
                    <arg>${errorprone.args}</arg>
                  </compilerArgs>
                </configuration>
              </execution>
            </executions>
            <dependencies>
              <dependency>
                <groupId>org.codehaus.plexus</groupId>
                <artifactId>plexus-compiler-javac-errorprone</artifactId>
                <version>2.8.5</version>
              </dependency>
              <dependency>
                <groupId>com.google.errorprone</groupId>
                <artifactId>error_prone_core</artifactId>
                <version>${errorprone.version}</version>
              </dependency>
            </dependencies>
          </plugin>
        </plugins>
      </build>
    </profile>
    <profile>
      <id>release</id>
      <build>
        <plugins>
          <!-- Creates source jar -->
          <plugin>
            <artifactId>maven-source-plugin</artifactId>
            <version>${maven-source-plugin.version}</version>
            <executions>
              <execution>
                <id>attach-sources</id>
                <goals>
                  <goal>jar</goal>
                </goals>
              </execution>
            </executions>
          </plugin>

          <plugin>
            <artifactId>maven-javadoc-plugin</artifactId>
            <version>${maven-javadoc-plugin.version}</version>
            <configuration>
              <failOnError>false</failOnError>
              <!-- hush pedantic warnings: we don't put param and return on everything! -->
              <doclint>none</doclint>
            </configuration>
            <executions>
              <execution>
                <id>attach-javadocs</id>
                <goals>
                  <goal>jar</goal>
                </goals>
                <phase>package</phase>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>
  </profiles>
</project>
