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

    Copyright 2016-2020 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.finagle2</groupId>
  <artifactId>zipkin-finagle-parent_2.13</artifactId>
  <version>2.2.1</version>
  <packaging>pom</packaging>

  <modules>
    <module>core</module>
    <module>kafka</module>
    <module>http</module>
    <module>scribe</module>
  </modules>

  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <project.build.resourceEncoding>UTF-8</project.build.resourceEncoding>
    <project.build.outputEncoding>UTF-8</project.build.outputEncoding>
    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
    <main.basedir>${project.basedir}</main.basedir>

    <!-- default bytecode version for src/main -->
    <main.java.version>1.8</main.java.version>
    <main.signature.artifact>java18</main.signature.artifact>

    <!-- default bytecode version for src/test -->
    <maven.compiler.source>1.8</maven.compiler.source>
    <maven.compiler.target>1.8</maven.compiler.target>

    <!-- override to set exclusions per-project: default to ignore warnings about flag naming -->
    <errorprone.args>-Xep:VariableNameSameAsType:OFF</errorprone.args>
    <errorprone.version>2.4.0</errorprone.version>

    <!-- version numbers that are used more than once -->
    <finagle.version>20.8.1</finagle.version>
    <log4j.version>2.13.3</log4j.version>
    <auto-value.version>1.7.4</auto-value.version>
    <zipkin-reporter.version>2.15.1</zipkin-reporter.version>
    <okhttp.version>4.8.1</okhttp.version>

    <maven-failsafe-plugin.version>3.0.0-M5</maven-failsafe-plugin.version>
    <license-maven-plugin.version>3.0</license-maven-plugin.version>
  </properties>

  <name>Zipkin Finagle (Parent)</name>
  <description>Zipkin Finagle (Parent)</description>
  <url>https://github.com/openzipkin/zipkin-finagle</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-finagle</url>
    <connection>scm:git:https://github.com/openzipkin/zipkin-finagle.git</connection>
    <developerConnection>scm:git:https://github.com/openzipkin/zipkin-finagle.git
    </developerConnection>
    <tag>2.2.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-finagle/;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-finagle/issues</url>
  </issueManagement>

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

      <dependency>
        <groupId>${project.groupId}</groupId>
        <artifactId>zipkin-finagle_2.13</artifactId>
        <version>${project.version}</version>
      </dependency>

      <dependency>
        <groupId>${project.groupId}</groupId>
        <artifactId>zipkin-finagle_2.13</artifactId>
        <type>test-jar</type>
        <version>${project.version}</version>
      </dependency>

      <!-- hard-set all the logger versions -->
      <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-api</artifactId>
        <version>1.7.30</version>
      </dependency>
      <dependency>
        <groupId>org.apache.logging.log4j</groupId>
        <artifactId>log4j-core</artifactId>
        <version>${log4j.version}</version>
      </dependency>
      <dependency>
        <groupId>org.apache.logging.log4j</groupId>
        <artifactId>log4j-jul</artifactId>
        <version>${log4j.version}</version>
      </dependency>
      <dependency>
        <groupId>org.apache.logging.log4j</groupId>
        <artifactId>log4j-slf4j-impl</artifactId>
        <version>${log4j.version}</version>
        <exclusions>
          <exclusion>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
          </exclusion>
        </exclusions>
      </dependency>
      <dependency>
        <groupId>org.apache.logging.log4j</groupId>
        <artifactId>log4j-1.2-api</artifactId>
        <version>${log4j.version}</version>
      </dependency>
      <dependency>
        <groupId>com.squareup.okhttp3</groupId>
        <artifactId>okhttp-tls</artifactId>
        <version>${okhttp.version}</version>
      </dependency>
      <dependency>
        <groupId>com.squareup.okhttp3</groupId>
        <artifactId>mockwebserver</artifactId>
        <version>${okhttp.version}</version>
      </dependency>
    </dependencies>
  </dependencyManagement>

  <dependencies>
    <dependency>
      <groupId>com.twitter</groupId>
      <artifactId>finagle-zipkin-core_2.13</artifactId>
      <version>${finagle.version}</version>
      <exclusions>
        <exclusion>
          <groupId>org.apache.thrift</groupId>
          <artifactId>libthrift</artifactId>
        </exclusion>
      </exclusions>
    </dependency>

    <dependency>
      <groupId>io.zipkin.zipkin2</groupId>
      <artifactId>zipkin</artifactId>
    </dependency>

    <dependency>
      <groupId>io.zipkin.reporter2</groupId>
      <artifactId>zipkin-reporter</artifactId>
    </dependency>

    <dependency>
      <groupId>com.google.auto.value</groupId>
      <artifactId>auto-value-annotations</artifactId>
      <version>${auto-value.version}</version>
    </dependency>
    <dependency>
      <groupId>com.google.auto.service</groupId>
      <artifactId>auto-service</artifactId>
      <version>1.0-rc7</version>
      <scope>provided</scope>
    </dependency>

    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>4.13</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.assertj</groupId>
      <artifactId>assertj-core</artifactId>
      <version>3.17.1</version>
      <scope>test</scope>
    </dependency>

    <!-- Main code uses jul and tests log with log4j -->
    <dependency>
      <groupId>org.apache.logging.log4j</groupId>
      <artifactId>log4j-core</artifactId>
      <scope>test</scope>
    </dependency>
    <!-- route jul over log4j2 during tests -->
    <dependency>
      <groupId>org.apache.logging.log4j</groupId>
      <artifactId>log4j-jul</artifactId>
      <scope>test</scope>
    </dependency>
    <!-- route log4j over log4j2 during tests -->
    <dependency>
      <groupId>org.apache.logging.log4j</groupId>
      <artifactId>log4j-1.2-api</artifactId>
      <scope>test</scope>
    </dependency>
    <!-- route slf4j over log4j2 during tests -->
    <dependency>
      <groupId>org.apache.logging.log4j</groupId>
      <artifactId>log4j-slf4j-impl</artifactId>
      <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.7</version>
          <configuration>
            <maven>3.6.3</maven>
          </configuration>
        </plugin>

        <plugin>
          <artifactId>maven-compiler-plugin</artifactId>
          <version>3.8.1</version>
          <inherited>true</inherited>
          <configuration>
            <!-- Retrolambda will rewrite lambdas as lower version Java bytecode if needed -->
            <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>3.2.0</version>
        </plugin>

        <plugin>
          <artifactId>maven-shade-plugin</artifactId>
          <version>3.2.4</version>
        </plugin>

        <plugin>
          <artifactId>maven-surefire-plugin</artifactId>
          <version>${maven-failsafe-plugin.version}</version>
          <configuration>
            <systemPropertyVariables>
              <java.util.logging.manager>org.apache.logging.log4j.jul.LogManager
              </java.util.logging.manager>
            </systemPropertyVariables>
          </configuration>
        </plugin>
        <plugin>
          <artifactId>maven-failsafe-plugin</artifactId>
          <version>${maven-failsafe-plugin.version}</version>
          <!-- Try to prevent flakes in circleci -->
          <configuration>
            <reuseForks>false</reuseForks>
            <systemPropertyVariables>
              <java.util.logging.manager>org.apache.logging.log4j.jul.LogManager
              </java.util.logging.manager>
            </systemPropertyVariables>
          </configuration>
        </plugin>

        <!-- manual only as CI keeps breaking due to incorrect git dates -->
        <plugin>
          <groupId>com.mycila</groupId>
          <artifactId>license-maven-plugin</artifactId>
          <version>${license-maven-plugin.version}</version>
          <configuration>
            <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>.gitignore</exclude>
              <exclude>.mvn/**</exclude>
              <exclude>mvnw*</exclude>
              <exclude>etc/header.txt</exclude>
              <exclude>**/.idea/**</exclude>
              <exclude>LICENSE</exclude>
              <exclude>**/*.md</exclude>
              <exclude>src/test/resources/**</exclude>
              <exclude>src/main/resources/**</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>
      </plugins>
    </pluginManagement>

    <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>
              <forceJavacCompilerUse>true</forceJavacCompilerUse>
              <compilerArgs>
                <arg>-XDcompilePolicy=simple</arg>
                <arg>-Xplugin:ErrorProne ${errorprone.args}</arg>
              </compilerArgs>
              <annotationProcessorPaths>
                <path>
                  <groupId>com.google.auto.value</groupId>
                  <artifactId>auto-value</artifactId>
                  <version>${auto-value.version}</version>
                </path>
                <processorPath>
                  <groupId>com.google.errorprone</groupId>
                  <artifactId>error_prone_core</artifactId>
                  <version>${errorprone.version}</version>
                </processorPath>
              </annotationProcessorPaths>
            </configuration>
          </execution>
        </executions>
      </plugin>

      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>animal-sniffer-maven-plugin</artifactId>
        <version>1.19</version>
        <configuration>
          <signature>
            <groupId>org.codehaus.mojo.signature</groupId>
            <artifactId>${main.signature.artifact}</artifactId>
            <version>1.0</version>
          </signature>
        </configuration>
        <executions>
          <execution>
            <goals>
              <goal>check</goal>
            </goals>
          </execution>
        </executions>
      </plugin>

      <plugin>
        <artifactId>maven-install-plugin</artifactId>
        <version>3.0.0-M1</version>
      </plugin>
      <!-- Uploads occur as a last step (which also adds checksums) -->
      <plugin>
        <artifactId>maven-deploy-plugin</artifactId>
        <version>3.0.0-M1</version>
      </plugin>
      <plugin>
        <artifactId>maven-release-plugin</artifactId>
        <version>3.0.0-M1</version>
        <configuration>
          <useReleaseProfile>false</useReleaseProfile>
          <releaseProfiles>release</releaseProfiles>
          <autoVersionSubmodules>true</autoVersionSubmodules>
          <!-- to match zipkin-scala (openzipkin/zipkin) -->
          <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-finagle</packageName>
        </configuration>
      </plugin>

      <plugin>
        <artifactId>maven-enforcer-plugin</artifactId>
        <version>3.0.0-M3</version>
        <executions>
          <execution>
            <id>enforce-java</id>
            <goals>
              <goal>enforce</goal>
            </goals>
            <configuration>
              <rules>
                <requireJavaVersion>
                  <version>[11,15)</version>
                </requireJavaVersion>
              </rules>
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>

  <profiles>
    <profile>
      <id>release</id>
      <build>
        <plugins>
          <!-- Creates source jar -->
          <plugin>
            <artifactId>maven-source-plugin</artifactId>
            <version>3.2.1</version>
            <executions>
              <execution>
                <id>attach-sources</id>
                <goals>
                  <goal>jar</goal>
                </goals>
              </execution>
            </executions>
          </plugin>

          <plugin>
            <artifactId>maven-javadoc-plugin</artifactId>
            <version>3.2.0</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>
    <profile>
      <id>sonatype</id>
      <distributionManagement>
        <repository>
          <id>sonatype</id>
          <url>https://oss.sonatype.org/service/local/staging/deploy/maven2</url>
        </repository>
      </distributionManagement>
      <build>
        <plugins>
          <plugin>
            <artifactId>maven-gpg-plugin</artifactId>
            <version>1.6</version>
            <executions>
              <execution>
                <id>sign-release-artifacts</id>
                <goals>
                  <goal>sign</goal>
                </goals>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>
  </profiles>
</project>
