<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>

  <groupId>io.jenkins.tools</groupId>
  <artifactId>central-repository-pom</artifactId>
  <version>1.7</version>
  <packaging>pom</packaging>

  <name>Root POM for Publishing Jenkins tooling to the central repository</name>
  <description>${project.name}</description>
  <url>https://github.com/jenkinsci/central-repository-pom</url>
  <licenses>
    <license>
      <name>MIT license</name>
      <url>https://opensource.org/license/mit/</url>
      <distribution>repo</distribution>
    </license>
  </licenses>

  <developers>
    <developer>
      <id>notmyfault</id>
      <name>Alexander Brandes</name>
      <email>contact(at)notmyfault.dev</email>
      <roles>
        <role>release</role>
        <role>maintainer</role>
      </roles>
    </developer>
    <developer>
      <id>jglick2</id>
      <name>Jesse Glick</name>
      <email>jglick@cloudbees.com</email>
      <roles>
        <role>release</role>
      </roles>
    </developer>
    <developer>
      <id>rsandell</id>
      <name>Robert Sandell</name>
      <email>rsandell@cloudbees.com</email>
      <roles>
        <role>release</role>
      </roles>
    </developer>
    <developer>
      <id>basilcrow</id>
      <name>Basil Crow</name>
      <roles>
        <role>release</role>
      </roles>
    </developer>
  </developers>

  <scm>
    <connection>scm:git:git@github.com/jenkinsci/${project.artifactId}.git</connection>
    <developerConnection>scm:git:ssh://git@github.com/jenkinsci/${project.artifactId}.git</developerConnection>
    <tag>central-repository-pom-1.7</tag>
    <url>https://github.com/jenkinsci/${project.artifactId}</url>
  </scm>

  <properties>
    <maven.compiler.release>17</maven.compiler.release>
    <maven.compiler.testRelease>${maven.compiler.release}</maven.compiler.testRelease>
    <!-- Generate metadata for reflection on method parameters -->
    <maven.compiler.parameters>true</maven.compiler.parameters>

    <!--
      The following bug patterns are noisy and create little value; therefore, we suppress them
      globally.

      ConstructorThrow
        CT_CONSTRUCTOR_THROW
      FindReturnRef
        EI_EXPOSE_BUF2
        EI_EXPOSE_REP
        EI_EXPOSE_REP2
        EI_EXPOSE_STATIC_BUF2
        EI_EXPOSE_STATIC_REP2
        MS_EXPOSE_BUF
        MS_EXPOSE_REP
      MultipleInstantiationsOfSingletons
        SING_SINGLETON_GETTER_NOT_SYNCHRONIZED
        SING_SINGLETON_HAS_NONPRIVATE_CONSTRUCTOR
        SING_SINGLETON_IMPLEMENTS_CLONEABLE
        SING_SINGLETON_IMPLEMENTS_CLONE_METHOD
        SING_SINGLETON_IMPLEMENTS_SERIALIZABLE
        SING_SINGLETON_INDIRECTLY_IMPLEMENTS_CLONEABLE
      SharedVariableAtomicityDetector
        AT_NONATOMIC_64BIT_PRIMITIVE
        AT_NONATOMIC_OPERATIONS_ON_SHARED_VARIABLE
        AT_STALE_THREAD_WRITE_OF_PRIMITIVE
      ThrowingExceptions
        THROWS_METHOD_THROWS_CLAUSE_BASIC_EXCEPTION
        THROWS_METHOD_THROWS_CLAUSE_THROWABLE
        THROWS_METHOD_THROWS_RUNTIMEEXCEPTION
    -->
    <spotbugs.omitVisitors>ConstructorThrow,FindReturnRef,MultipleInstantiationsOfSingletons,SharedVariableAtomicityDetector,ThrowingExceptions</spotbugs.omitVisitors>

    <!-- Set to false to enable Spotless -->
    <spotless.check.skip>true</spotless.check.skip>

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

    <maven-clean-plugin.version>3.5.0</maven-clean-plugin.version>
    <maven-compiler-plugin.version>3.15.0</maven-compiler-plugin.version>
    <maven-dependency-plugin.version>3.10.0</maven-dependency-plugin.version>
    <maven-deploy-plugin.version>3.1.4</maven-deploy-plugin.version>
    <maven-gpg-plugin.version>3.2.8</maven-gpg-plugin.version>
    <maven-install-plugin.version>3.1.4</maven-install-plugin.version>
    <maven-jar-plugin.version>3.5.0</maven-jar-plugin.version>
    <maven-javadoc-plugin.version>3.12.0</maven-javadoc-plugin.version>
    <maven-project-info-reports-plugin.version>3.9.0</maven-project-info-reports-plugin.version>
    <maven-release-plugin.version>3.3.1</maven-release-plugin.version>
    <maven-resources-plugin.version>3.5.0</maven-resources-plugin.version>
    <maven-source-plugin.version>3.4.0</maven-source-plugin.version>
    <maven-surefire-plugin.version>3.5.5</maven-surefire-plugin.version>
    <central-publishing-maven-plugin.version>0.10.0</central-publishing-maven-plugin.version>
    <spotbugs-annotations.version>4.9.8</spotbugs-annotations.version>
    <spotbugs-maven-plugin.version>4.9.8.3</spotbugs-maven-plugin.version>
    <spotless-maven-plugin.version>3.4.0</spotless-maven-plugin.version>
  </properties>

  <dependencyManagement>
    <dependencies>
      <dependency>
        <groupId>com.github.spotbugs</groupId>
        <artifactId>spotbugs-annotations</artifactId>
        <version>${spotbugs-annotations.version}</version>
      </dependency>
    </dependencies>
  </dependencyManagement>

  <build>
    <pluginManagement>
      <plugins>
        <plugin>
          <groupId>com.diffplug.spotless</groupId>
          <artifactId>spotless-maven-plugin</artifactId>
          <version>${spotless-maven-plugin.version}</version>
        </plugin>
        <plugin>
          <groupId>com.github.spotbugs</groupId>
          <artifactId>spotbugs-maven-plugin</artifactId>
          <version>${spotbugs-maven-plugin.version}</version>
        </plugin>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-clean-plugin</artifactId>
          <version>${maven-clean-plugin.version}</version>
        </plugin>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-compiler-plugin</artifactId>
          <version>${maven-compiler-plugin.version}</version>
        </plugin>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-dependency-plugin</artifactId>
          <version>${maven-dependency-plugin.version}</version>
        </plugin>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-deploy-plugin</artifactId>
          <version>${maven-deploy-plugin.version}</version>
        </plugin>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-gpg-plugin</artifactId>
          <version>${maven-gpg-plugin.version}</version>
        </plugin>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-javadoc-plugin</artifactId>
          <version>${maven-javadoc-plugin.version}</version>
        </plugin>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-install-plugin</artifactId>
          <version>${maven-install-plugin.version}</version>
        </plugin>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-project-info-reports-plugin</artifactId>
          <version>${maven-project-info-reports-plugin.version}</version>
        </plugin>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-surefire-plugin</artifactId>
          <version>${maven-surefire-plugin.version}</version>
        </plugin>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-jar-plugin</artifactId>
          <version>${maven-jar-plugin.version}</version>
        </plugin>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-release-plugin</artifactId>
          <version>${maven-release-plugin.version}</version>
        </plugin>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-resources-plugin</artifactId>
          <version>${maven-resources-plugin.version}</version>
        </plugin>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-source-plugin</artifactId>
          <version>${maven-source-plugin.version}</version>
        </plugin>
        <plugin>
          <groupId>org.sonatype.central</groupId>
          <artifactId>central-publishing-maven-plugin</artifactId>
          <version>${central-publishing-maven-plugin.version}</version>
        </plugin>
      </plugins>
    </pluginManagement>
    <plugins>
      <plugin>
        <groupId>com.github.spotbugs</groupId>
        <artifactId>spotbugs-maven-plugin</artifactId>
        <executions>
          <execution>
            <id>spotbugs</id>
            <goals>
              <goal>check</goal>
            </goals>
            <phase>verify</phase>
            <!--
              Do not define "excludeFilterFile" here, as it will force consumers to provide a file.
              Instead, we configure this below in a profile conditionally activated based on the
              presence of this file.
            -->
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>com.diffplug.spotless</groupId>
        <artifactId>spotless-maven-plugin</artifactId>
        <configuration>
          <java>
            <endWithNewline />
            <importOrder />
            <indent>
              <spaces>true</spaces>
            </indent>
            <palantirJavaFormat>
              <!-- Declare version so that spotless does not choose a version based on JDK version -->
              <!-- https://github.com/diffplug/spotless/issues/2503#issuecomment-2953146277 -->
              <version>2.73.0</version>
            </palantirJavaFormat>
            <removeUnusedImports />
            <trimTrailingWhitespace />
          </java>
          <pom>
            <sortPom>
              <expandEmptyElements>false</expandEmptyElements>
              <sortDependencies>scope,groupId,artifactId</sortDependencies>
              <sortDependencyExclusions>groupId,artifactId</sortDependencyExclusions>
              <spaceBeforeCloseEmptyElement>true</spaceBeforeCloseEmptyElement>
            </sortPom>
          </pom>
        </configuration>
        <executions>
          <execution>
            <goals>
              <goal>check</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-javadoc-plugin</artifactId>
        <configuration>
          <doclint>all,-missing</doclint>
          <locale>en_US</locale>
          <notimestamp>true</notimestamp>
        </configuration>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-release-plugin</artifactId>
        <configuration>
          <releaseProfiles>jenkins-release</releaseProfiles>
        </configuration>
      </plugin>
      <plugin>
        <groupId>org.sonatype.central</groupId>
        <artifactId>central-publishing-maven-plugin</artifactId>
        <extensions>true</extensions>
        <configuration>
          <publishingServerId>central</publishingServerId>
          <autoPublish>true</autoPublish>
          <checksums>all</checksums>
        </configuration>
      </plugin>
    </plugins>
    <extensions>
      <extension>
        <groupId>org.apache.maven.scm</groupId>
        <artifactId>maven-scm-provider-gitexe</artifactId>
        <version>2.2.1</version>
      </extension>
      <extension>
        <groupId>org.apache.maven.scm</groupId>
        <artifactId>maven-scm-manager-plexus</artifactId>
        <version>2.2.1</version>
      </extension>
    </extensions>
  </build>

  <reporting>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-project-info-reports-plugin</artifactId>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-javadoc-plugin</artifactId>
      </plugin>
    </plugins>
  </reporting>

  <profiles>
    <profile>
      <id>jenkins-release</id>
      <build>
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-gpg-plugin</artifactId>
            <executions>
              <execution>
                <id>sign-artifacts</id>
                <goals>
                  <goal>sign</goal>
                </goals>
                <phase>verify</phase>
                <configuration>
                  <gpgArguments>
                    <arg>--pinentry-mode</arg>
                    <arg>loopback</arg>
                  </gpgArguments>
                </configuration>
              </execution>
            </executions>
          </plugin>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-source-plugin</artifactId>
            <executions>
              <execution>
                <id>attach-sources</id>
                <goals>
                  <goal>jar-no-fork</goal>
                </goals>
              </execution>
            </executions>
          </plugin>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-javadoc-plugin</artifactId>
            <executions>
              <execution>
                <id>attach-javadocs</id>
                <goals>
                  <goal>jar</goal>
                </goals>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>
    <profile>
      <id>spotbugs-exclusion-file</id>
      <activation>
        <file>
          <exists>${basedir}/src/spotbugs/excludesFilter.xml</exists>
        </file>
      </activation>
      <build>
        <plugins>
          <plugin>
            <groupId>com.github.spotbugs</groupId>
            <artifactId>spotbugs-maven-plugin</artifactId>
            <executions>
              <execution>
                <id>spotbugs</id>
                <configuration>
                  <excludeFilterFile>${project.basedir}/src/spotbugs/excludesFilter.xml</excludeFilterFile>
                </configuration>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>
    <profile>
      <id>may-spotless-apply</id>
      <build>
        <plugins>
          <plugin>
            <groupId>com.diffplug.spotless</groupId>
            <artifactId>spotless-maven-plugin</artifactId>
            <executions>
              <execution>
                <id>spotless-apply</id>
                <goals>
                  <goal>apply</goal>
                </goals>
                <phase>validate</phase>
                <configuration>
                  <skip>${spotless.check.skip}</skip>
                </configuration>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>
  </profiles>
</project>
