<?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.opentracing.brave</groupId>
  <artifactId>brave-opentracing</artifactId>
  <name>Zipkin OpenTracing Brave</name>
  <url>https://github.com/openzipkin-contrib/opentracing-brave</url>
  <description>Zipkin OpenTracing Brave bridge</description>
  <inceptionYear>2016</inceptionYear>

  <version>0.37.5</version>

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

    <brave.version>5.13.1</brave.version>

    <!-- default bytecode version for src/main -->
    <main.java.version>1.6</main.java.version>
    <main.signature.artifact>java16</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>

    <!-- disable errorprone override warning as this allows us to support different versions -->
    <errorprone.args>-Xep:MissingOverride:OFF</errorprone.args>
    <errorprone.version>2.4.0</errorprone.version>

    <!-- versions needed also for integration tests -->
    <junit.version>4.13.1</junit.version>
    <assertj.version>3.18.0</assertj.version>
    <mockito.version>3.6.0</mockito.version>
    <junit-dataprovider.version>2.6</junit-dataprovider.version>

    <!-- TODO: cleanup any redundant ignores now also in the 4.0 release (once final) -->
    <license-maven-plugin.version>4.0.rc2</license-maven-plugin.version>
    <maven-compiler-plugin.version>3.8.1</maven-compiler-plugin.version>
    <maven-jar-plugin.version>3.2.0</maven-jar-plugin.version>
    <maven-surefire-plugin.version>3.0.0-M5</maven-surefire-plugin.version>
    <nexus-staging-maven-plugin.version>1.6.8</nexus-staging-maven-plugin.version>
  </properties>

  <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-contrib/brave-opentracing</url>
    <connection>scm:git:https://github.com/openzipkin-contrib/brave-opentracing.git</connection>
    <developerConnection>scm:git:https://github.com/openzipkin-contrib/brave-opentracing.git
    </developerConnection>
    <tag>0.37.5</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>
    <snapshotRepository>
      <id>ossrh</id>
      <url>https://oss.sonatype.org/content/repositories/snapshots</url>
    </snapshotRepository>
    <repository>
      <id>ossrh</id>
      <url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
    </repository>
  </distributionManagement>

  <issueManagement>
    <system>Github</system>
    <url>https://github.com/openzipkin-contrib/brave-opentracing/issues</url>
  </issueManagement>

  <dependencies>
    <dependency>
      <groupId>io.opentracing</groupId>
      <artifactId>opentracing-api</artifactId>
      <version>0.32.0</version>
    </dependency>
    <dependency>
      <groupId>io.zipkin.brave</groupId>
      <artifactId>brave</artifactId>
      <version>${brave.version}</version>
    </dependency>

    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>${junit.version}</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>io.zipkin.brave</groupId>
      <artifactId>brave-tests</artifactId>
      <version>${brave.version}</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.mockito</groupId>
      <artifactId>mockito-core</artifactId>
      <version>${mockito.version}</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.assertj</groupId>
      <artifactId>assertj-core</artifactId>
      <version>${assertj.version}</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>com.tngtech.junit.dataprovider</groupId>
      <artifactId>junit4-dataprovider</artifactId>
      <version>${junit-dataprovider.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.7</version>
          <configuration>
            <maven>3.6.3</maven>
          </configuration>
        </plugin>

        <!-- mvn de.qaware.maven:go-offline-maven-plugin:resolve-dependencies -->
        <plugin>
          <groupId>de.qaware.maven</groupId>
          <artifactId>go-offline-maven-plugin</artifactId>
          <version>1.2.7</version>
          <configuration>
            <dynamicDependencies>
              <!-- src/it/opentracing-0.31/pom.xml -->
              <dynamicDependency>
                <groupId>io.opentracing</groupId>
                <artifactId>opentracing-api</artifactId>
                <version>0.31.0</version>
                <repositoryType>MAIN</repositoryType>
              </dynamicDependency>
              <!-- src/it/opentracing-0.33/pom.xml -->
              <dynamicDependency>
                <groupId>io.opentracing</groupId>
                <artifactId>opentracing-api</artifactId>
                <version>0.33.0</version>
                <repositoryType>MAIN</repositoryType>
              </dynamicDependency>
            </dynamicDependencies>
          </configuration>
        </plugin>

        <plugin>
          <artifactId>maven-install-plugin</artifactId>
          <version>3.0.0-M1</version>
        </plugin>

        <plugin>
          <artifactId>maven-jar-plugin</artifactId>
          <version>${maven-jar-plugin.version}</version>
          <configuration>
            <archive>
              <!-- prevents huge pom file from also being added to the jar under META-INF/maven -->
              <addMavenDescriptor>false</addMavenDescriptor>
            </archive>
          </configuration>
        </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>
            <tagNameFormat>@{project.version}</tagNameFormat>
          </configuration>
        </plugin>

        <plugin>
          <groupId>org.sonatype.plugins</groupId>
          <artifactId>nexus-staging-maven-plugin</artifactId>
          <version>${nexus-staging-maven-plugin.version}</version>
        </plugin>
      </plugins>
    </pluginManagement>

    <plugins>
      <plugin>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>${maven-compiler-plugin.version}</version>
        <inherited>true</inherited>
        <configuration>
          <!-- Retrolambda will rewrite lambdas as Java 6 bytecode -->
          <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-surefire-plugin</artifactId>
        <version>${maven-surefire-plugin.version}</version>
      </plugin>

      <plugin>
        <groupId>net.orfjackal.retrolambda</groupId>
        <artifactId>retrolambda-maven-plugin</artifactId>
        <version>2.5.7</version>
        <executions>
          <execution>
            <goals>
              <goal>process-main</goal>
            </goals>
            <configuration>
              <target>${main.java.version}</target>
              <fork>true</fork>
              <quiet>true</quiet>
            </configuration>
          </execution>
        </executions>
      </plugin>

      <!-- Language-level aside, make sure Java 9 types and methods aren't used -->
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>animal-sniffer-maven-plugin</artifactId>
        <version>1.19</version>
        <configuration>
          <checkTestClasses>false</checkTestClasses>
          <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-enforcer-plugin</artifactId>
        <version>3.0.0-M3</version>
        <executions>
          <execution>
            <id>enforce-java</id>
            <goals>
              <goal>enforce</goal>
            </goals>
            <configuration>
              <rules>
                <!-- Cannot use JDK 15 until Retrolambda supports it
                     https://github.com/luontola/retrolambda/issues/161 -->
                <requireJavaVersion>
                  <version>[11,15)</version>
                </requireJavaVersion>
              </rules>
            </configuration>
          </execution>
        </executions>
      </plugin>

      <plugin>
        <artifactId>maven-invoker-plugin</artifactId>
        <version>3.2.1</version>
        <configuration>
          <cloneProjectsTo>${project.build.directory}/it</cloneProjectsTo>
          <settingsFile>${main.basedir}/src/it/settings.xml</settingsFile>
          <profiles>
            <profile>!release</profile>
          </profiles>
          <localRepositoryPath>${project.build.directory}/local-repo</localRepositoryPath>
          <postBuildHookScript>verify</postBuildHookScript>
          <addTestClassPath>true</addTestClassPath>
          <skipInvocation>${skipTests}</skipInvocation>
          <streamLogs>true</streamLogs>
          <mavenOpts>-Dorg.slf4j.simpleLogger.defaultLogLevel=WARN</mavenOpts>
        </configuration>
        <executions>
          <execution>
            <goals>
              <goal>install</goal>
              <goal>run</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>

  <profiles>
    <!-- -DskipTests ensures license libraries aren't required when packaging -->
    <profile>
      <id>check-license</id>
      <activation>
        <property>
          <name>!skipTests</name>
        </property>
      </activation>
      <build>
        <plugins>
          <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>
                <!-- build-bin/docker -->
                <block_on_health>SCRIPT_STYLE</block_on_health>
                <configure_docker>SCRIPT_STYLE</configure_docker>
                <configure_docker_push>SCRIPT_STYLE</configure_docker_push>
                <docker_arch>SCRIPT_STYLE</docker_arch>
                <docker_args>SCRIPT_STYLE</docker_args>
                <docker_build>SCRIPT_STYLE</docker_build>
                <docker_push>SCRIPT_STYLE</docker_push>
                <!-- build-bin/git -->
                <login_git>SCRIPT_STYLE</login_git>
                <version_from_trigger_tag>SCRIPT_STYLE</version_from_trigger_tag>
                <!-- build-bin/gpg -->
                <configure_gpg>SCRIPT_STYLE</configure_gpg>
                <!-- build-bin/maven -->
                <maven_build_or_unjar>SCRIPT_STYLE</maven_build_or_unjar>
                <maven_deploy>SCRIPT_STYLE</maven_deploy>
                <maven_go_offline>SCRIPT_STYLE</maven_go_offline>
                <maven_release>SCRIPT_STYLE</maven_release>
                <maven_unjar>SCRIPT_STYLE</maven_unjar>
              </mapping>
              <excludes>
                <exclude>.docker.env</exclude>
                <exclude>.gitignore</exclude>
                <exclude>.editorconfig</exclude>
                <exclude>.mvn/**</exclude>
                <exclude>mvnw*</exclude>
                <exclude>etc/header.txt</exclude>
                <exclude>**/.idea/**</exclude>
                <exclude>LICENSE</exclude>
                <exclude>**/*.md</exclude>
                <exclude>**/bnd.bnd</exclude>
                <exclude>src/test/resources/**</exclude>
                <exclude>src/main/resources/**</exclude>
                <exclude>build-bin/*</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>
      </build>
    </profile>

    <profile>
      <id>error-prone</id>
      <activation>
        <activeByDefault>true</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>
                  <forceJavacCompilerUse>true</forceJavacCompilerUse>
                  <compilerArgs>
                    <arg>-XDcompilePolicy=simple</arg>
                    <arg>-Xplugin:ErrorProne ${errorprone.args}</arg>
                  </compilerArgs>
                  <annotationProcessorPaths>
                    <processorPath>
                      <groupId>com.google.errorprone</groupId>
                      <artifactId>error_prone_core</artifactId>
                      <version>${errorprone.version}</version>
                    </processorPath>
                  </annotationProcessorPaths>
                </configuration>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>

    <profile>
      <id>release</id>
      <build>
        <plugins>
          <plugin>
            <groupId>org.sonatype.plugins</groupId>
            <artifactId>nexus-staging-maven-plugin</artifactId>
            <extensions>true</extensions>
            <configuration>
              <serverId>ossrh</serverId>
              <nexusUrl>https://oss.sonatype.org/</nexusUrl>
              <!-- Double the normal timeout even though we haven't had a problem in this project.
                   The only outcome of timing out client side is trying again. -->
              <stagingProgressTimeoutMinutes>10</stagingProgressTimeoutMinutes>
              <autoReleaseAfterClose>true</autoReleaseAfterClose>
            </configuration>
          </plugin>

          <plugin>
            <artifactId>maven-gpg-plugin</artifactId>
            <version>1.6</version>
            <executions>
              <execution>
                <id>sign-artifacts</id>
                <phase>verify</phase>
                <goals>
                  <goal>sign</goal>
                </goals>
                <configuration>
                  <gpgArguments>
                    <arg>--pinentry-mode</arg>
                    <arg>loopback</arg>
                  </gpgArguments>
                </configuration>
              </execution>
            </executions>
          </plugin>

          <plugin>
            <artifactId>maven-enforcer-plugin</artifactId>
            <executions>
              <execution>
                <id>enforce-java</id>
                <goals>
                  <goal>enforce</goal>
                </goals>
                <configuration>
                  <rules>
                    <!-- JDK 12+ can no longer generate Java 1.6 bytecode, so we require JDK 11.
                         https://www.oracle.com/java/technologies/javase/12-relnote-issues.html -->
                    <requireJavaVersion>
                      <version>[11,12)</version>
                    </requireJavaVersion>
                  </rules>
                </configuration>
              </execution>
            </executions>
          </plugin>

          <!-- 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>
              <!-- While we publish modules, our source is pre-Java9 so tell javadoc that. -->
              <source>8</source>
            </configuration>
            <executions>
              <execution>
                <id>attach-javadocs</id>
                <goals>
                  <goal>jar</goal>
                </goals>
                <phase>package</phase>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>
  </profiles>
</project>
