<?xml version="1.0" encoding="UTF-8"?>
<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>co.elastic.apm</groupId>
    <artifactId>apm-agent-parent</artifactId>
    <version>1.16.0</version>
    <packaging>pom</packaging>

    <name>${project.groupId}:${project.artifactId}</name>

    <inceptionYear>2018</inceptionYear>

    <organization>
        <name>Elastic Inc.</name>
        <url>https://www.elastic.co</url>
    </organization>

    <description>APM for Java applications with the Elastic stack</description>
    <url>https://github.com/elastic/apm-agent-java</url>

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

    <scm>
        <connection>scm:git:git@github.com:elastic/apm-agent-java.git</connection>
        <developerConnection>scm:git:git@github.com:elastic/apm-agent-java.git</developerConnection>
        <url>https://github.com/elastic/apm-agent-java</url>
        <tag>v1.16.0</tag>
    </scm>

    <developers>
        <developer>
            <name>Elastic</name>
            <url>https://discuss.elastic.co/c/apm</url>
            <organization>Elastic Inc.</organization>
            <organizationUrl>https://www.elastic.co</organizationUrl>
        </developer>
    </developers>

    <distributionManagement>
        <snapshotRepository>
            <id>sonatype-nexus-snapshots</id>
            <url>https://oss.sonatype.org/content/repositories/snapshots</url>
        </snapshotRepository>
        <repository>
            <id>sonatype-nexus-staging</id>
            <url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
        </repository>
    </distributionManagement>

    <modules>
        <module>apm-agent-core</module>
        <module>elastic-apm-agent</module>
        <module>apm-agent-benchmarks</module>
        <module>apm-agent-plugins</module>
        <module>apm-agent-api</module>
        <module>apm-opentracing</module>
        <module>integration-tests</module>
        <module>apm-agent-attach</module>
    </modules>

    <properties>

        <maven.compiler.target>7</maven.compiler.target>
        <maven.compiler.testTarget>9</maven.compiler.testTarget>
        <animal.sniffer.skip>false</animal.sniffer.skip>
        <!--
        mockserver-client does not work with the latest jackson version
        see https://github.com/jamesdbloom/mockserver/issues/440
        -->
        <maven.compiler.showWarnings>true</maven.compiler.showWarnings>
        <maven.compiler.errorprone>true</maven.compiler.errorprone>
        <!--
        By default, artifacts are part of the deployment (mvn deploy:deploy).
        But the artifacts of some projects should not be deployed (to maven central for example).
        -->
        <maven-deploy-plugin.skip>false</maven-deploy-plugin.skip>

        <!-- -dependencies versions -->
        <version.error_prone>2.2.0</version.error_prone>
        <version.h2>1.4.196</version.h2>
        <version.jackson>[2.10.0,)</version.jackson>
        <version.junit-jupiter>5.4.2</version.junit-jupiter>
        <version.junit.vintage>4.12</version.junit.vintage>
        <version.junit-vintage-engine>5.3.2</version.junit-vintage-engine>
        <version.logback>1.2.3</version.logback>
        <version.okhttp>3.9.1</version.okhttp>
        <version.slf4j>1.7.25</version.slf4j>
        <version.log4j>2.12.1</version.log4j>
        <version.spring>5.0.15.RELEASE</version.spring>
        <version.jetty-server>9.4.11.v20180605</version.jetty-server>
        <version.json-schema-validator>0.1.19</version.json-schema-validator>
        <version.byte-buddy>1.10.8</version.byte-buddy>

        <!-- used both for plugin & annotations dependency -->
        <version.animal-sniffer>1.17</version.animal-sniffer>

        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>

        <apm-agent-parent.base.dir>${project.basedir}</apm-agent-parent.base.dir>

        <skip.integration.test>false</skip.integration.test>
        <skip.unit.test>false</skip.unit.test>
    </properties>

    <profiles>
        <!--
        This profile is needed to be active in IntelliJ
        as it does not understand that the tests have a different target version
        -->
        <profile>
            <id>IntelliJ</id>
            <activation>
                <activeByDefault>false</activeByDefault>
            </activation>
            <properties>
                <maven.compiler.target>10</maven.compiler.target>
            </properties>
        </profile>
        <profile>
          <id>integration-test-only</id>
          <activation>
              <activeByDefault>false</activeByDefault>
          </activation>
          <properties>
              <skip.unit.test>true</skip.unit.test>
              <skip.integration.test>false</skip.integration.test>
          </properties>
          <build>
            <plugins>
              <plugin>
                  <artifactId>maven-failsafe-plugin</artifactId>
                  <configuration>
                    <skipTests>${skip.integration.test}</skipTests>
                  </configuration>
              </plugin>
              <plugin>
                  <artifactId>maven-surefire-plugin</artifactId>
                  <configuration>
                      <enableAssertions>true</enableAssertions>
                      <trimStackTrace>false</trimStackTrace>
                      <skipTests>${skip.unit.test}</skipTests>
                  </configuration>
              </plugin>
            </plugins>
          </build>
        </profile>
        <profile>
            <id>no-errorprone</id>
            <activation>
                <property>
                    <name>!maven.compiler.errorprone</name>
                </property>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <artifactId>maven-compiler-plugin</artifactId>
                        <configuration>
                            <showWarnings>${maven.compiler.showWarnings}</showWarnings>
                            <source>${maven.compiler.target}</source>
                            <target>${maven.compiler.target}</target>
                            <testSource>${maven.compiler.testTarget}</testSource>
                            <testTarget>${maven.compiler.testTarget}</testTarget>
                            <encoding>UTF-8</encoding>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <id>errorprone</id>
            <activation>
                <activeByDefault>false</activeByDefault>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <artifactId>maven-compiler-plugin</artifactId>
                        <configuration>
                            <compilerId>javac-with-errorprone</compilerId>
                            <forceJavacCompilerUse>true</forceJavacCompilerUse>
                            <showWarnings>${maven.compiler.showWarnings}</showWarnings>
                            <source>${maven.compiler.target}</source>
                            <target>${maven.compiler.target}</target>
                            <testSource>${maven.compiler.testTarget}</testSource>
                            <testTarget>${maven.compiler.testTarget}</testTarget>
                            <encoding>UTF-8</encoding>
                            <annotationProcessorPaths>
                                <path>
                                    <groupId>com.uber.nullaway</groupId>
                                    <artifactId>nullaway</artifactId>
                                    <version>0.4.1</version>
                                </path>
                            </annotationProcessorPaths>
                            <compilerArgs>
                                <arg>-Xep:NullAway:ERROR</arg>
                                <arg>-XepOpt:NullAway:AnnotatedPackages=co.elastic.apm</arg>
                            </compilerArgs>
                        </configuration>
                        <dependencies>
                            <dependency>
                                <groupId>org.codehaus.plexus</groupId>
                                <artifactId>plexus-compiler-javac-errorprone</artifactId>
                                <version>2.8.3</version>
                            </dependency>
                            <!-- override plexus-compiler-javac-errorprone's dependency on
                                 Error Prone with the latest version -->
                            <dependency>
                                <groupId>com.google.errorprone</groupId>
                                <artifactId>error_prone_core</artifactId>
                                <version>${version.error_prone}</version>
                            </dependency>
                        </dependencies>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <!-- Sign all artifacts (requires gpg installation). -->
        <profile>
            <id>gpg</id>
            <activation>
                <activeByDefault>false</activeByDefault>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <artifactId>maven-gpg-plugin</artifactId>
                        <executions>
                            <execution>
                                <phase>verify</phase>
                                <goals>
                                    <goal>sign</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>

    <build>
        <plugins>
            <plugin>
                <artifactId>maven-release-plugin</artifactId>
                <configuration>
                    <useReleaseProfile>false</useReleaseProfile>
                    <releaseProfiles>gpg</releaseProfiles>
                    <autoVersionSubmodules>true</autoVersionSubmodules>
                    <tagNameFormat>v@{project.version}</tagNameFormat>
                    <checkModificationExcludes>
                        <checkModificationExclude>**/apm-agent-benchmarks/src/main/resources/**</checkModificationExclude>
                        <checkModificationExclude>**/apm-agent-plugins/apm-profiling-plugin/src/main/resources/**</checkModificationExclude>
                    </checkModificationExcludes>
                </configuration>
            </plugin>
            <plugin>
                <artifactId>maven-deploy-plugin</artifactId>
                <configuration>
                    <skip>${maven-deploy-plugin.skip}</skip>
                </configuration>
            </plugin>
            <!-- The shadowed source files of this module need to be included explicitly to create a javadoc artifact.-->
            <plugin>
                <artifactId>maven-javadoc-plugin</artifactId>
                <configuration>
                    <additionalOptions>-html5</additionalOptions>
                </configuration>
                <executions>
                    <execution>
                        <goals>
                            <goal>jar</goal>
                        </goals>
                    </execution>
                </executions>

            </plugin>
            <!-- Check that we don't accidentally use features only available in Java 8+ -->
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>animal-sniffer-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <id>signature-check</id>
                        <phase>verify</phase>
                        <goals>
                            <goal>check</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <skip>${animal.sniffer.skip}</skip>
                    <signature>
                        <groupId>org.codehaus.mojo.signature</groupId>
                        <artifactId>java17</artifactId>
                        <version>1.0</version>
                    </signature>
                    <!--work around for https://github.com/mojohaus/animal-sniffer/issues/18-->
                    <ignores>java.lang.invoke.MethodHandle</ignores>
                </configuration>
            </plugin>
            <plugin>
                <artifactId>maven-enforcer-plugin</artifactId>
                <executions>
                    <execution>
                        <id>enforce-java</id>
                        <goals>
                            <goal>enforce</goal>
                        </goals>
                        <configuration>
                            <rules>
                                <requireJavaVersion>
                                    <version>${maven.compiler.testTarget}</version>
                                </requireJavaVersion>
                            </rules>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <artifactId>maven-surefire-plugin</artifactId>
                <configuration>
                    <enableAssertions>true</enableAssertions>
                    <trimStackTrace>false</trimStackTrace>
                </configuration>
            </plugin>
            <plugin>
                <artifactId>maven-failsafe-plugin</artifactId>
                <executions>
                    <execution>
                        <goals>
                            <goal>integration-test</goal>
                            <goal>verify</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>org.jacoco</groupId>
                <artifactId>jacoco-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <goals>
                            <goal>prepare-agent</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>report</id>
                        <phase>test</phase>
                        <goals>
                            <goal>report</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <!-- License headers -->
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>license-maven-plugin</artifactId>
                <configuration>
                    <verbose>false</verbose>
                    <licenseName>apache2_license</licenseName>
                    <licenseResolver>file:///${apm-agent-parent.base.dir}/licenses</licenseResolver>
                    <addJavaLicenseAfterPackage>false</addJavaLicenseAfterPackage>
                    <failOnMissingHeader>true</failOnMissingHeader>
                    <failOnNotUptodateHeader>true</failOnNotUptodateHeader>
                    <projectName>Elastic APM Java agent</projectName>
                    <!--
                    Elastic does actually not have the copyright of community contributions.
                    See https://www.elastic.co/contributor-agreement
                    "The CLA is a license agreement, which enables Elastic to distribute your code without restriction.
                    It doesn't require you to assign to us any copyright you have, the ownership of which remains in full with you.
                    You cannot withdraw permission for its use at a later date."
                    -->
                    <organizationName>Elastic and contributors</organizationName>
                    <roots>
                        <root>src/main/java</root>
                        <root>src/test/java</root>
                    </roots>
                </configuration>
                <executions>
                    <execution>
                        <id>first</id>
                        <goals>
                            <goal>update-file-header</goal>
                        </goals>
                        <phase>process-sources</phase>
                    </execution>
                    <execution>
                        <id>license-header-check</id>
                        <goals>
                            <goal>check-file-header</goal>
                        </goals>
                        <phase>verify</phase>
                    </execution>
                </executions>
            </plugin>

        </plugins>

        <pluginManagement>
            <!-- pin and set plugin versions at parent project level -->
            <plugins>
                <plugin>
                    <artifactId>maven-assembly-plugin</artifactId>
                    <version>3.2.0</version>
                </plugin>
                <plugin>
                    <artifactId>maven-source-plugin</artifactId>
                    <version>3.2.0</version>
                </plugin>
                <plugin>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <version>3.8.1</version>
                </plugin>
                <plugin>
                    <artifactId>maven-surefire-plugin</artifactId>
                    <version>2.19.1</version>
                    <dependencies>
                        <dependency>
                            <groupId>org.junit.platform</groupId>
                            <artifactId>junit-platform-surefire-provider</artifactId>
                            <version>1.1.1</version>
                        </dependency>
                        <dependency>
                            <groupId>org.junit.vintage</groupId>
                            <artifactId>junit-vintage-engine</artifactId>
                            <version>${version.junit-vintage-engine}</version>
                        </dependency>
                        <dependency>
                            <groupId>org.junit.jupiter</groupId>
                            <artifactId>junit-jupiter-engine</artifactId>
                            <version>${version.junit-jupiter}</version>
                        </dependency>
                    </dependencies>
                </plugin>
                <plugin>
                    <artifactId>maven-failsafe-plugin</artifactId>
                    <version>2.19.1</version>
                </plugin>
                <plugin>
                    <artifactId>maven-jar-plugin</artifactId>
                    <version>3.2.0</version>
                </plugin>
                <plugin>
                    <artifactId>maven-dependency-plugin</artifactId>
                    <version>3.1.1</version>
                </plugin>
                <plugin>
                    <artifactId>maven-release-plugin</artifactId>
                    <version>2.5.3</version>
                </plugin>
                <plugin>
                    <artifactId>maven-gpg-plugin</artifactId>
                    <version>1.6</version>
                </plugin>
                <plugin>
                    <artifactId>maven-deploy-plugin</artifactId>
                    <version>2.8.2</version>
                </plugin>
                <plugin>
                    <artifactId>maven-javadoc-plugin</artifactId>
                    <version>3.1.1</version>
                    <dependencies>
                        <!--
                        The transitive dependency has version 3.5,
                        which is not compatible with Java 10.
                        TODO Remove this when updating the javadoc plugin version.
                        -->
                        <dependency>
                            <groupId>org.apache.commons</groupId>
                            <artifactId>commons-lang3</artifactId>
                            <version>3.7</version>
                        </dependency>
                    </dependencies>
                </plugin>
                <plugin>
                    <groupId>org.codehaus.mojo</groupId>
                    <artifactId>animal-sniffer-maven-plugin</artifactId>
                    <version>${version.animal-sniffer}</version>
                </plugin>
                <plugin>
                    <artifactId>maven-enforcer-plugin</artifactId>
                    <version>3.0.0-M1</version>
                </plugin>
                <plugin>
                    <groupId>org.jacoco</groupId>
                    <artifactId>jacoco-maven-plugin</artifactId>
                    <version>0.8.2</version>
                </plugin>
                <plugin>
                    <groupId>org.codehaus.mojo</groupId>
                    <artifactId>license-maven-plugin</artifactId>
                    <version>1.19</version>
                </plugin>
                <plugin>
                    <groupId>com.coderplus.maven.plugins</groupId>
                    <artifactId>copy-rename-maven-plugin</artifactId>
                    <version>1.0</version>
                </plugin>
                <plugin>
                    <artifactId>maven-shade-plugin</artifactId>
                    <version>3.2.1</version>
                </plugin>
                <plugin>
                    <artifactId>maven-clean-plugin</artifactId>
                    <version>3.1.0</version>
                </plugin>
                <plugin>
                    <artifactId>maven-install-plugin</artifactId>
                    <version>3.0.0-M1</version>
                </plugin>
                <plugin>
                    <artifactId>maven-resources-plugin</artifactId>
                    <version>3.1.0</version>
                </plugin>
                <plugin>
                    <artifactId>maven-site-plugin</artifactId>
                    <version>3.8.2</version>
                </plugin>
            </plugins>
        </pluginManagement>
    </build>

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.testcontainers</groupId>
                <artifactId>testcontainers-bom</artifactId>
                <version>1.10.6</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <dependencies>
        <dependency>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>animal-sniffer-annotations</artifactId>
            <version>${version.animal-sniffer}</version>
            <optional>true</optional>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.google.code.findbugs</groupId>
            <artifactId>jsr305</artifactId>
            <version>3.0.2</version>
            <optional>true</optional>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-api</artifactId>
            <version>${version.junit-jupiter}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-params</artifactId>
            <version>${version.junit-jupiter}</version>
            <scope>test</scope>
        </dependency>
        <!-- JUnit 4 to make legacy JUnit 4 tests compile -->
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>${version.junit.vintage}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.assertj</groupId>
            <artifactId>assertj-core</artifactId>
            <version>3.12.2</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.mockito</groupId>
            <artifactId>mockito-core</artifactId>
            <version>3.3.3</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.networknt</groupId>
            <artifactId>json-schema-validator</artifactId>
            <version>${version.json-schema-validator}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-databind</artifactId>
            <version>${version.jackson}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.eclipse.jetty</groupId>
            <artifactId>jetty-servlet</artifactId>
            <version>${version.jetty-server}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.github.tomakehurst</groupId>
            <artifactId>wiremock-standalone</artifactId>
            <version>2.18.0</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.awaitility</groupId>
            <artifactId>awaitility</artifactId>
            <version>4.0.1</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.ivy</groupId>
            <artifactId>ivy</artifactId>
            <version>2.5.0</version>
            <scope>test</scope>
        </dependency>
    </dependencies>

</project>
