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

    Copyright 2017-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.brave.play</groupId>
  <artifactId>play-zipkin-tracing-parent_2.12</artifactId>
  <version>3.0.3</version>

  <packaging>pom</packaging>

  <modules>
    <module>core</module>
    <module>akka</module>
    <module>play</module>
  </modules>

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

    <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>

    <!-- 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>

    <scala-library.version>2.12.11</scala-library.version>
    <brave.version>5.13.3</brave.version>
    <akka.version>2.6.10</akka.version>
    <play.version>2.7.9</play.version>

    <log4j.version>2.14.0</log4j.version>
    <junit.version>4.13.1</junit.version>
    <scalatest.version>3.0.9</scalatest.version>

    <license.skip>${skipTests}</license.skip>

    <genjavadoc-plugin.version>0.16</genjavadoc-plugin.version>
    <go-offline-maven-plugin.version>1.2.8</go-offline-maven-plugin.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>
    <!-- Use same version as https://github.com/openzipkin/docker-java -->
    <maven-dependency-plugin.version>3.1.2</maven-dependency-plugin.version>
    <maven-deploy-plugin.version>3.0.0-M1</maven-deploy-plugin.version>
    <maven-enforcer-plugin.version>3.0.0-M3</maven-enforcer-plugin.version>
    <!-- Use same version as https://github.com/openzipkin/docker-java -->
    <maven-help-plugin.version>3.2.0</maven-help-plugin.version>
    <maven-install-plugin.version>3.0.0-M1</maven-install-plugin.version>
    <maven-javadoc-plugin.version>3.2.0</maven-javadoc-plugin.version>
    <maven-jar-plugin.version>3.2.0</maven-jar-plugin.version>
    <maven-release-plugin.version>3.0.0-M1</maven-release-plugin.version>
    <maven-source-plugin.version>3.2.1</maven-source-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>
    <scala-maven-plugin.version>4.4.0</scala-maven-plugin.version>
  </properties>

  <name>Play Zipkin Tracing (Parent)</name>
  <description>Play Zipkin Tracing (Parent)</description>
  <url>https://github.com/openzipkin-contrib/play-zipkin-tracing</url>
  <inceptionYear>2017</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-contrib/play-zipkin-tracing</url>
    <connection>scm:git:https://github.com/openzipkin-contrib/play-zipkin-tracing.git</connection>
    <developerConnection>scm:git:https://github.com/openzipkin-contrib/play-zipkin-tracing.git</developerConnection>
    <tag>3.0.3</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/play-zipkin-tracing/issues</url>
  </issueManagement>

  <dependencyManagement>
    <!-- Play typically handles the bootstrap of a service, including configuration management
         with flags. We import the BOM for convenience, so those adding different reporters don't
         need to know the version used here. -->
    <dependencies>
      <dependency>
        <groupId>io.zipkin.brave</groupId>
        <artifactId>brave-bom</artifactId>
        <version>${brave.version}</version>
        <type>pom</type>
        <scope>import</scope>
      </dependency>
    </dependencies>
  </dependencyManagement>

  <dependencies>
    <dependency>
      <groupId>org.scala-lang</groupId>
      <artifactId>scala-library</artifactId>
      <version>${scala-library.version}</version>
      <scope>provided</scope>
    </dependency>

    <dependency>
      <groupId>io.zipkin.brave</groupId>
      <artifactId>brave</artifactId>
    </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>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.scalatest</groupId>
      <artifactId>scalatest_2.12</artifactId>
      <version>${scalatest.version}</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>com.novocode</groupId>
      <artifactId>junit-interface</artifactId>
      <version>0.11</version>
      <scope>test</scope>
    </dependency>

    <!-- route jul over log4j2 during tests -->
    <dependency>
      <groupId>org.apache.logging.log4j</groupId>
      <artifactId>log4j-jul</artifactId>
      <version>${log4j.version}</version>
      <scope>test</scope>
    </dependency>
    <!-- route log4j over log4j2 during tests -->
    <dependency>
      <groupId>org.apache.logging.log4j</groupId>
      <artifactId>log4j-1.2-api</artifactId>
      <version>${log4j.version}</version>
      <scope>test</scope>
    </dependency>
    <!-- route slf4j over log4j2 during tests -->
    <dependency>
      <groupId>org.apache.logging.log4j</groupId>
      <artifactId>log4j-slf4j-impl</artifactId>
      <version>${log4j.version}</version>
      <scope>test</scope>
    </dependency>
  </dependencies>

  <build>
    <sourceDirectory>${project.basedir}/src/main/scala</sourceDirectory>
    <testSourceDirectory>${project.basedir}/src/test/scala</testSourceDirectory>
    <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>${go-offline-maven-plugin.version}</version>
          <configuration>
            <dynamicDependencies>
              <!-- Add dependencies indirectly referenced by build plugins -->
              <DynamicDependency>
                <groupId>org.codehaus.mojo.signature</groupId>
                <artifactId>${main.signature.artifact}</artifactId>
                <version>1.0</version>
                <type>signature</type>
                <repositoryType>MAIN</repositoryType>
              </DynamicDependency>
              <DynamicDependency>
                <groupId>com.typesafe.genjavadoc</groupId>
                <artifactId>genjavadoc-plugin_${scala-library.version}</artifactId>
                <version>${genjavadoc-plugin.version}</version>
                <repositoryType>MAIN</repositoryType>
              </DynamicDependency>
              <DynamicDependency>
                <groupId>com.mycila</groupId>
                <artifactId>license-maven-plugin-git</artifactId>
                <version>${license-maven-plugin.version}</version>
                <repositoryType>MAIN</repositoryType>
              </DynamicDependency>
              <DynamicDependency>
                <groupId>org.apache.maven.surefire</groupId>
                <artifactId>surefire-junit-platform</artifactId>
                <version>${maven-surefire-plugin.version}</version>
                <repositoryType>PLUGIN</repositoryType>
              </DynamicDependency>
            </dynamicDependencies>
          </configuration>
        </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>
          <artifactId>maven-install-plugin</artifactId>
          <version>${maven-install-plugin.version}</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>

        <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>org.sonatype.plugins</groupId>
          <artifactId>nexus-staging-maven-plugin</artifactId>
          <version>${nexus-staging-maven-plugin.version}</version>
        </plugin>
      </plugins>
    </pluginManagement>

    <plugins>
      <!-- Ensure common utility commands use coherent versions (avoid lazy downloads) -->
      <plugin>
        <artifactId>maven-dependency-plugin</artifactId>
        <version>${maven-dependency-plugin.version}</version>
      </plugin>
      <plugin>
        <artifactId>maven-help-plugin</artifactId>
        <version>${maven-help-plugin.version}</version>
      </plugin>

      <plugin>
        <groupId>net.alchim31.maven</groupId>
        <artifactId>scala-maven-plugin</artifactId>
        <version>${scala-maven-plugin.version}</version>
        <configuration>
          <charset>${project.build.sourceEncoding}</charset>
          <scalaVersion>${scala-library.version}</scalaVersion>
        </configuration>
        <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>
      </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-surefire-plugin</artifactId>
        <version>${maven-surefire-plugin.version}</version>
      </plugin>

      <plugin>
        <artifactId>maven-enforcer-plugin</artifactId>
        <version>${maven-enforcer-plugin.version}</version>
        <executions>
          <execution>
            <id>enforce-java</id>
            <goals>
              <goal>enforce</goal>
            </goals>
            <configuration>
              <rules>
                <requireJavaVersion>
                  <version>[11,16)</version>
                </requireJavaVersion>
              </rules>
            </configuration>
          </execution>
        </executions>
      </plugin>

      <plugin>
        <groupId>com.mycila</groupId>
        <artifactId>license-maven-plugin</artifactId>
        <version>${license-maven-plugin.version}</version>
        <configuration>
          <skip>${license.skip}</skip>
          <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/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_opts>SCRIPT_STYLE</maven_opts>
            <maven_release>SCRIPT_STYLE</maven_release>
            <maven_unjar>SCRIPT_STYLE</maven_unjar>
          </mapping>
          <excludes>
            <exclude>.gitignore</exclude>
            <exclude>.editorconfig</exclude>
            <exclude>.mvn/**</exclude>
            <exclude>mvnw*</exclude>
            <exclude>etc/header.txt</exclude>
            <exclude>**/.idea/**</exclude>
            <exclude>sample/**</exclude>
            <exclude>LICENSE</exclude>
            <exclude>**/*.md</exclude>
            <exclude>**/build.properties</exclude>
            <exclude>**/application.conf</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>

    <resources>
      <!-- This adds the LICENSE and NOTICE file to the jar and -sources jar of each module -->
      <resource>
        <filtering>false</filtering>
        <directory>${main.basedir}</directory>
        <targetPath>META-INF/</targetPath>
        <includes>
          <include>LICENSE</include>
          <include>NOTICE</include>
        </includes>
      </resource>
    </resources>
  </build>

  <profiles>
    <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>

          <!-- 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>
            <groupId>org.scala-tools</groupId>
            <artifactId>maven-scala-plugin</artifactId>
            <version>2.15.2</version>
            <executions>
              <execution>
                <id>scala-compile-first</id>
                <phase>prepare-package</phase>
                <goals>
                  <goal>compile</goal>
                </goals>
                <configuration>
                  <args>
                    <arg>-P:genjavadoc:out=${project.build.directory}/genjavadoc</arg>
                  </args>
                  <compilerPlugins>
                    <compilerPlugin>
                      <groupId>com.typesafe.genjavadoc</groupId>
                      <artifactId>genjavadoc-plugin_${scala-library.version}</artifactId>
                      <version>${genjavadoc-plugin.version}</version>
                    </compilerPlugin>
                  </compilerPlugins>
                </configuration>
              </execution>
            </executions>
          </plugin>

          <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>build-helper-maven-plugin</artifactId>
            <version>3.2.0</version>
            <executions>
              <execution>
                <phase>package</phase>
                <goals>
                  <goal>add-source</goal>
                </goals>
                <configuration>
                  <sources>
                    <source>${project.build.directory}/genjavadoc</source>
                  </sources>
                </configuration>
              </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>
              <!-- 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>
