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

    Copyright 2013-2024 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</groupId>
  <artifactId>brave-parent</artifactId>
  <version>5.18.1</version>
  <packaging>pom</packaging>

  <name>Brave (parent)</name>
  <description>
    Java distributed tracing implementation compatible with Zipkin backend services.
  </description>
  <url>https://github.com/openzipkin/brave</url>
  <inceptionYear>2013</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/brave</url>
    <connection>scm:git:https://github.com/openzipkin/brave.git</connection>
    <developerConnection>scm:git:https://github.com/openzipkin/brave.git</developerConnection>
    <tag>5.18.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>

  <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 -->
    <maven.compiler.source>1.8</maven.compiler.source>
    <maven.compiler.target>1.8</maven.compiler.target>
    <!-- We don't use animal-sniffer anymore as release obviates it.
         See https://github.com/mojohaus/animal-sniffer/issues/62 -->
    <maven.compiler.release>8</maven.compiler.release>

    <!-- Tests use the floor Java version (used in release) -->
    <maven.compiler.testSource>11</maven.compiler.testSource>
    <maven.compiler.testTarget>11</maven.compiler.testTarget>
    <maven.compiler.testRelease>11</maven.compiler.testRelease>

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

    <!-- use the same values in bom/pom.xml -->
    <zipkin.version>2.27.0</zipkin.version>
    <zipkin-reporter.version>2.17.2</zipkin-reporter.version>

    <!-- Used for Generated annotations -->
    <javax-annotation-api.version>1.3.2</javax-annotation-api.version>
    <!-- to test @Inject annotations. Note 7.x is for jakarta annotations! -->
    <guice.version>6.0.0</guice.version>

    <!-- Ensure older versions of spring still work -->
    <spring5.version>5.3.31</spring5.version>
    <spring.version>3.2.18.RELEASE</spring.version>

    <!-- Apis used, but not in Jetty 7.6* imply duplication in servlet25 test fixtures -->
    <!-- prefer sparkjava's jetty to reduce downloads -->
    <jetty.version>9.4.53.v20231009</jetty.version>
    <jetty-servlet25.version>7.6.21.v20160908</jetty-servlet25.version>
    <resteasy.version>3.15.6.Final</resteasy.version>

    <!-- Jakarta -->
    <jetty11.version>11.0.19</jetty11.version>
    <jakarta.servlet>5.0.0</jakarta.servlet>

    <kafka.version>3.6.1</kafka.version>
    <activemq.version>5.18.3</activemq.version>
    <activemq.artemis.version>2.31.2</activemq.artemis.version>
    <!-- TODO: reflection drift after this version -->
    <spring-rabbit.version>2.3.6</spring-rabbit.version>

    <!-- TODO: update and fix drift or remove the FinagleContextInteropTest -->
    <finagle.version>20.12.0</finagle.version>
    <log4j.version>2.22.1</log4j.version>
    <okhttp.version>4.12.0</okhttp.version>
    <httpclient.version>4.5.14</httpclient.version>

    <!-- TODO: grpc removed code we use in tests saying is wasn't used.
         Port the attachHeaders code from here.
         https://github.com/grpc/grpc-java/commit/a589eacc8f83c80bb44c8fae0b0b173b5ff51e61 -->
    <grpc.version>1.57.2</grpc.version>
    <protobuf.version>3.22.3</protobuf.version>
    <!-- prefer grpc's version of netty -->
    <netty.version>4.1.93.Final</netty.version>

    <httpasyncclient.version>4.1.5</httpasyncclient.version>
    <sparkjava.version>2.9.4</sparkjava.version>

    <!-- Test only dependencies -->
    <junit-jupiter.version>5.10.1</junit-jupiter.version>
    <assertj.version>3.25.1</assertj.version>
    <mockito.version>5.8.0</mockito.version>
    <jersey.version>2.41</jersey.version>
    <testcontainers.version>1.19.3</testcontainers.version>

    <license.skip>${skipTests}</license.skip>
    <maven-surefire-plugin.argLine />
    <maven-failsafe-plugin.argLine />

    <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.3</license-maven-plugin.version>
    <maven-bundle-plugin.version>5.1.9</maven-bundle-plugin.version>
    <maven-compiler-plugin.version>3.12.1</maven-compiler-plugin.version>
    <!-- Use same version as https://github.com/openzipkin/docker-java -->
    <maven-dependency-plugin.version>3.6.1</maven-dependency-plugin.version>
    <maven-deploy-plugin.version>3.1.1</maven-deploy-plugin.version>
    <maven-enforcer-plugin.version>3.4.1</maven-enforcer-plugin.version>
    <!-- Use same version as https://github.com/openzipkin/docker-java -->
    <maven-help-plugin.version>3.4.0</maven-help-plugin.version>
    <maven-install-plugin.version>3.1.1</maven-install-plugin.version>
    <maven-invoker-plugin.version>3.6.0</maven-invoker-plugin.version>
    <maven-javadoc-plugin.version>3.6.3</maven-javadoc-plugin.version>
    <maven-jar-plugin.version>3.3.0</maven-jar-plugin.version>
    <maven-release-plugin.version>3.0.1</maven-release-plugin.version>
    <maven-shade-plugin.version>3.5.1</maven-shade-plugin.version>
    <maven-source-plugin.version>3.3.0</maven-source-plugin.version>
    <maven-surefire-plugin.version>3.2.3</maven-surefire-plugin.version>
    <nexus-staging-maven-plugin.version>1.6.13</nexus-staging-maven-plugin.version>
  </properties>

  <modules>
    <module>brave</module>
    <module>brave-bom</module>
    <module>brave-tests</module>
    <module>context</module>
    <module>instrumentation</module>
    <module>spring-beans</module>
  </modules>

  <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/brave/issues</url>
  </issueManagement>

  <dependencyManagement>
    <!-- Be careful here, especially to not import BOMs as io.zipkin.brave:brave has this parent.

         For example, if you imported Netty's BOM here, using Brave would also download that BOM. As
         Brave is indirectly used, this can be extremely confusing when people are troubleshooting
         library version assignments. -->
  </dependencyManagement>

  <dependencies>
    <!-- Do not add compile dependencies here. This can cause problems for libraries that depend on
         io.zipkin.brave:brave difficult to unravel. -->
    <dependency>
      <groupId>org.junit.jupiter</groupId>
      <artifactId>junit-jupiter</artifactId>
      <version>${junit-jupiter.version}</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.assertj</groupId>
      <artifactId>assertj-core</artifactId>
      <version>${assertj.version}</version>
      <exclusions>
        <!-- Use newer bytebuddy from mockito, which is JRE 21 compatible.
             TODO: remove when assertj releases a new version -->
        <exclusion>
          <groupId>net.bytebuddy</groupId>
          <artifactId>*</artifactId>
        </exclusion>
      </exclusions>
      <scope>test</scope>
    </dependency>
    <!-- Main code uses jul and tests log with log4j -->
    <dependency>
      <groupId>org.apache.logging.log4j</groupId>
      <artifactId>log4j-core</artifactId>
      <version>${log4j.version}</version>
      <scope>test</scope>
    </dependency>
    <!-- route jul over log4j2 during integration 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 integration 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 integration tests -->
    <dependency>
      <groupId>org.apache.logging.log4j</groupId>
      <artifactId>log4j-slf4j-impl</artifactId>
      <version>${log4j.version}</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.mockito</groupId>
      <artifactId>mockito-junit-jupiter</artifactId>
      <version>${mockito.version}</version>
      <scope>test</scope>
    </dependency>
  </dependencies>

  <build>
    <pluginManagement>
      <plugins>
        <!-- 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>
            <!-- Add dependencies indirectly referenced by build plugins -->
            <dynamicDependencies>
              <DynamicDependency>
                <groupId>com.mycila</groupId>
                <artifactId>license-maven-plugin-git</artifactId>
                <version>${license-maven-plugin.version}</version>
                <repositoryType>MAIN</repositoryType>
              </DynamicDependency>
              <DynamicDependency>
                <groupId>com.google.errorprone</groupId>
                <artifactId>error_prone_core</artifactId>
                <version>${errorprone.version}</version>
                <repositoryType>MAIN</repositoryType>
                <type>jar</type>
              </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>

        <plugin>
          <artifactId>maven-compiler-plugin</artifactId>
          <version>${maven-compiler-plugin.version}</version>
          <inherited>true</inherited>
          <configuration>
            <fork>true</fork>
            <showWarnings>true</showWarnings>
          </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>

        <plugin>
          <groupId>org.eclipse.m2e</groupId>
          <artifactId>lifecycle-mapping</artifactId>
          <version>1.0.0</version>
          <configuration>
            <lifecycleMappingMetadata>
              <pluginExecutions>
                <pluginExecution>
                  <pluginExecutionFilter>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <versionRange>[3.7,)</versionRange>
                    <goals>
                      <goal>compile</goal>
                      <goal>testCompile</goal>
                    </goals>
                  </pluginExecutionFilter>
                  <action>
                    <configurator>
                      <id>org.eclipse.m2e.jdt.javaConfigurator</id>
                    </configurator>
                  </action>
                </pluginExecution>
              </pluginExecutions>
            </lifecycleMappingMetadata>
          </configuration>
        </plugin>
        <plugin>
          <artifactId>maven-eclipse-plugin</artifactId>
          <version>2.10</version>
          <configuration>
            <downloadSources>true</downloadSources>
            <downloadJavadocs>true</downloadJavadocs>
          </configuration>
        </plugin>

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

        <plugin>
          <artifactId>maven-invoker-plugin</artifactId>
          <version>${maven-invoker-plugin.version}</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>
            <!--- Don't use addTestClassPath as it interferes with the classpath -->
            <postBuildHookScript>verify</postBuildHookScript>
            <skipInvocation>${skipTests}</skipInvocation>
            <streamLogs>true</streamLogs>
            <!-- Silences repetitive "downloading" logs from the local repo.
                 Note: this also silences logs about integration test runs! -->
            <mavenOpts>-Dorg.slf4j.simpleLogger.defaultLogLevel=WARN</mavenOpts>
          </configuration>
          <executions>
            <execution>
              <goals>
                <goal>install</goal>
                <goal>run</goal>
              </goals>
            </execution>
          </executions>
        </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>
        <artifactId>maven-surefire-plugin</artifactId>
        <version>${maven-surefire-plugin.version}</version>
        <configuration>
          <!-- Ensure scope leak cause ends up in the console -->
          <trimStackTrace>false</trimStackTrace>
          <!-- Don't add org.apache.logging.log4j.jul.LogManager here as it conflicts with
               classloading, causing brave.test.propagation.PropagationTest to flake. -->
          <classpathDependencyExcludes>
            <classpathDependencyExclude>org.apache.logging.log4j:log4j-jul</classpathDependencyExclude>
          </classpathDependencyExcludes>
          <argLine>${maven-surefire-plugin.argLine}</argLine>
        </configuration>
      </plugin>

      <plugin>
        <artifactId>maven-failsafe-plugin</artifactId>
        <version>${maven-surefire-plugin.version}</version>
        <executions>
          <execution>
            <id>integration-test</id>
            <phase>verify</phase>
            <goals>
              <goal>integration-test</goal>
              <goal>verify</goal>
            </goals>
          </execution>
        </executions>
        <configuration>
          <!-- Try to prevent flakes in CI -->
          <reuseForks>false</reuseForks>
          <!-- workaround to SUREFIRE-1831 -->
          <useModulePath>false</useModulePath>
          <!-- Ensure scope leak cause ends up in the console -->
          <trimStackTrace>false</trimStackTrace>
          <argLine>${maven-failsafe-plugin.argLine}</argLine>
        </configuration>
      </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>
                  <!-- Change this to control LTS JDK versions allowed to build
                       the project. Keep in sync with .github/workflows -->
                  <version>[11,12),[17,18),[21,22)</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>
          <!-- 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>
            <bnd>SCRIPT_STYLE</bnd>
            <!-- build-bin/docker -->
            <configure_docker>SCRIPT_STYLE</configure_docker>
            <!-- 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_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>
          </mapping>
          <excludes>
            <exclude>**/jetty-logging.properties</exclude>
            <exclude>**/log4j2.properties</exclude>
            <exclude>.editorconfig</exclude>
            <exclude>.gitattributes</exclude>
            <exclude>.gitignore</exclude>
            <exclude>.mailmap</exclude>
            <exclude>.mvn/**</exclude>
            <exclude>mvnw*</exclude>
            <exclude>etc/header.txt</exclude>
            <exclude>**/.idea/**</exclude>
            <exclude>**/.editorconfig</exclude>
            <exclude>LICENSE</exclude>
            <exclude>NOTICE</exclude>
            <exclude>**/*.md</exclude>
            <exclude>**/*.bnd</exclude>
            <exclude>src/test/resources/**</exclude>
            <exclude>.github/**</exclude>
            <exclude>build-bin/*</exclude>
            <!-- instrumentation/dubbo -->
            <exclude>**/com.alibaba.dubbo.rpc.Filter</exclude>
            <!-- instrumentation/grpc -->
            <exclude>src/test/proto/**</exclude>
            <!-- generated grpc 1.2 test sources -->
            <exclude>**/Hello*.java</exclude>
            <exclude>**/GreeterGrpc*.java</exclude>
            <exclude>**/GraterGrpc*.java</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>
      <resource>
        <filtering>false</filtering>
        <directory>src/main/resources</directory>
      </resource>
      <resource>
        <filtering>false</filtering>
        <directory>src/main/java</directory>
        <includes>
          <include>**</include>
        </includes>
        <excludes>
          <exclude>**/*.java</exclude>
        </excludes>
      </resource>
      <!-- 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>
    <testResources>
      <testResource>
        <filtering>false</filtering>
        <directory>src/test/java</directory>
        <includes>
          <include>**</include>
        </includes>
        <excludes>
          <exclude>**/*.java</exclude>
        </excludes>
      </testResource>
      <testResource>
        <filtering>false</filtering>
        <directory>src/test/resources</directory>
      </testResource>
    </testResources>
  </build>

  <profiles>
    <!-- -DskipTests ensures benchmarks don't end up in javadocs or in Maven Central -->
    <profile>
      <id>include-benchmarks</id>
      <activation>
        <property>
          <name>!skipTests</name>
        </property>
      </activation>
      <modules>
        <module>instrumentation/benchmarks</module>
      </modules>
    </profile>

    <profile>
      <id>error-prone-11+</id>
      <activation>
        <!-- Only LTS versions -->
        <jdk>[11,12),[17,18),[21,22)</jdk>
      </activation>
      <build>
        <plugins>
          <plugin>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>${maven-compiler-plugin.version}</version>
            <inherited>true</inherited>
            <configuration>
              <fork>true</fork>
              <showWarnings>true</showWarnings>
            </configuration>
            <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>
                    <!-- below needed for JDK16+ per https://errorprone.info/docs/installation -->
                    <arg>-J--add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED</arg>
                    <arg>-J--add-exports=jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED</arg>
                    <arg>-J--add-exports=jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED</arg>
                    <arg>-J--add-exports=jdk.compiler/com.sun.tools.javac.model=ALL-UNNAMED</arg>
                    <arg>-J--add-exports=jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED</arg>
                    <arg>-J--add-exports=jdk.compiler/com.sun.tools.javac.processing=ALL-UNNAMED</arg>
                    <arg>-J--add-exports=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED</arg>
                    <arg>-J--add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED</arg>
                    <arg>-J--add-opens=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED</arg>
                    <arg>-J--add-opens=jdk.compiler/com.sun.tools.javac.comp=ALL-UNNAMED</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>
              <!-- Recent slowdowns with Sonatype staging have pushed latencies over 10-20 minutes.
                   Increasing the timeout avoids failures and retries, which still often fail when
                   Sonatype servers are overloaded. -->
              <stagingProgressTimeoutMinutes>30</stagingProgressTimeoutMinutes>
              <autoReleaseAfterClose>true</autoReleaseAfterClose>
            </configuration>
          </plugin>

          <plugin>
            <artifactId>maven-gpg-plugin</artifactId>
            <version>3.1.0</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>

          <!-- Creates javadoc jar, skipping internal classes -->
          <plugin>
            <artifactId>maven-javadoc-plugin</artifactId>
            <version>${maven-javadoc-plugin.version}</version>
            <configuration>
              <sourceFileExcludes>
                <exclude>**/internal/*.java</exclude>
                <exclude>**/Internal*.java</exclude>
              </sourceFileExcludes>
              <excludePackageNames>*.internal.*</excludePackageNames>
              <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>

    <profile>
      <id>module-info</id>
      <!-- Build profiles can only consider static properties, such as files or ENV variables.
           To conditionally add module information, we use existence of bnd.bnd. This allows
           irrelevant packages such as tests and benchmarks to quietly opt-out.
           http://maven.apache.org/guides/introduction/introduction-to-profiles.html -->
      <activation>
        <file>
          <exists>bnd.bnd</exists>
        </file>
      </activation>
      <build>
        <plugins>
          <!-- OSGi and Java Modules configuration -->
          <plugin>
            <groupId>org.apache.felix</groupId>
            <artifactId>maven-bundle-plugin</artifactId>
            <version>${maven-bundle-plugin.version}</version>
            <configuration>
              <obrRepository>NONE</obrRepository>
              <instructions>
                <_include>-bnd.bnd</_include>
              </instructions>
            </configuration>
            <executions>
              <execution>
                <phase>process-classes</phase>
                <goals>
                  <goal>manifest</goal>
                </goals>
              </execution>
            </executions>
          </plugin>
          <plugin>
            <artifactId>maven-jar-plugin</artifactId>
            <executions>
              <execution>
                <id>default-jar</id>
                <configuration>
                  <archive>
                    <!-- Include the MANIFEST.MF maven-bundle-plugin generates from bnd.bnd -->
                    <manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
                    <manifestEntries>
                      <Automatic-Module-Name>${module.name}</Automatic-Module-Name>
                    </manifestEntries>
                  </archive>
                </configuration>
                <goals>
                  <goal>jar</goal>
                </goals>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>
  </profiles>
</project>
