central-publishing-maven-plugin
Used in: 
components
- OverviewOverview
- VersionsVersions
- DependentsDependents
- DependenciesDependencies
<dependency>
    <groupId>org.sonatype.central</groupId>
    <artifactId>central-publishing-maven-plugin</artifactId>
    <version>0.9.0</version>
</dependency><?xml version="1.0" encoding="UTF-8"?>
<!--
    Copyright (c) 2022-present Sonatype, Inc. All rights reserved.
    "Sonatype" is a trademark of Sonatype, Inc.
-->
<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>org.sonatype.central</groupId>
  <artifactId>central-publishing-maven-plugin</artifactId>
  <version>0.9.0</version>
  <packaging>maven-plugin</packaging>
  <name>Central Publishing Maven Plugin</name>
  <description>
    This project is a maven plugin for publishing components in Maven Central, for more details
    on its usage see https://central.sonatype.org/publish/publish-portal-maven
  </description>
  <licenses>
    <license>
      <name>The Apache License, Version 2.0</name>
      <url>https://www.apache.org/licenses/LICENSE-2.0.txt</url>
    </license>
  </licenses>
  <scm>
    <url>https://github.com/sonatype/central-publishing-maven-plugin</url>
  </scm>
  <url>https://central.sonatype.org</url>
  <parent>
    <groupId>org.sonatype.buildsupport</groupId>
    <artifactId>buildsupport</artifactId>
    <version>32</version>
  </parent>
  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <maven.compiler.source>8</maven.compiler.source>
    <maven.compiler.target>8</maven.compiler.target>
  </properties>
  <dependencies>
    <dependency>
      <groupId>org.apache.maven</groupId>
      <artifactId>maven-plugin-api</artifactId>
      <version>3.9.2</version>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>org.apache.maven.plugin-tools</groupId>
      <artifactId>maven-plugin-annotations</artifactId>
      <version>3.8.2</version>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-invoker-plugin</artifactId>
      <version>3.5.1</version>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>org.apache.maven</groupId>
      <artifactId>maven-compat</artifactId>
      <version>3.9.0</version>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>org.codehaus.plexus</groupId>
      <artifactId>plexus-utils</artifactId>
      <version>3.5.1</version>
    </dependency>
    <dependency>
      <groupId>com.github.package-url</groupId>
      <artifactId>packageurl-java</artifactId>
      <version>1.4.1</version>
    </dependency>
    <dependency>
      <groupId>com.google.guava</groupId>
      <artifactId>guava</artifactId>
      <version>32.1.0-jre</version>
    </dependency>
    <dependency>
      <groupId>commons-io</groupId>
      <artifactId>commons-io</artifactId>
      <version>2.15.1</version>
    </dependency>
    <dependency>
      <groupId>org.apache.commons</groupId>
      <artifactId>commons-lang3</artifactId>
      <version>3.18.0</version>
    </dependency>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>4.13.2</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.hamcrest</groupId>
      <artifactId>hamcrest</artifactId>
      <version>2.2</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.mockito</groupId>
      <artifactId>mockito-core</artifactId>
      <version>4.8.1</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.mock-server</groupId>
      <artifactId>mockserver-client-java</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>com.fasterxml.jackson.core</groupId>
      <artifactId>jackson-databind</artifactId>
      <version>2.16.1</version>
    </dependency>
    <dependency>
      <groupId>org.apache.httpcomponents.client5</groupId>
      <artifactId>httpclient5</artifactId>
      <version>5.3.1</version>
      <exclusions>
        <exclusion>
          <artifactId>commons-logging</artifactId>
          <groupId>commons-logging</groupId>
        </exclusion>
      </exclusions>
    </dependency>
  </dependencies>
  <dependencyManagement>
    <dependencies>
      <dependency>
        <groupId>org.mock-server</groupId>
        <artifactId>mockserver-client-java</artifactId>
        <version>5.15.0</version>
        <exclusions>
          <exclusion>
            <groupId>org.yaml</groupId>
            <artifactId>snakeyaml</artifactId>
          </exclusion>
        </exclusions>
      </dependency>
    </dependencies>
  </dependencyManagement>
  <build>
    <pluginManagement>
      <plugins>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-invoker-plugin</artifactId>
          <version>3.5.1</version>
          <configuration>
            <writeJunitReport>true</writeJunitReport>
            <cloneProjectsTo>${project.build.directory}/it</cloneProjectsTo>
            <pomIncludes>
              <pomInclude>*/pom.xml</pomInclude>
            </pomIncludes>
            <preBuildHookScript>setup</preBuildHookScript>
            <postBuildHookScript>verify</postBuildHookScript>
            <localRepositoryPath>${project.build.directory}/local-repo</localRepositoryPath>
            <settingsFile>src/it/settings.xml</settingsFile>
            <properties>
              <centralBaseUrl>http://localhost:${mockcentral.port}</centralBaseUrl>
              <centralSnapshotsUrl>http://localhost:${mockcentral.port}/snapshots/</centralSnapshotsUrl>
            </properties>
            <goals>
              <goal>deploy</goal>
            </goals>
          </configuration>
          <executions>
            <execution>
              <id>integration-test</id>
              <goals>
                <goal>install</goal>
                <goal>integration-test</goal>
                <goal>verify</goal>
              </goals>
            </execution>
          </executions>
        </plugin>
        <plugin>
          <groupId>org.codehaus.plexus</groupId>
          <artifactId>plexus-component-metadata</artifactId>
          <version>2.1.1</version>
        </plugin>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-plugin-plugin</artifactId>
          <version>3.8.2</version>
          <configuration>
            <goalPrefix>central-publishing</goalPrefix>
          </configuration>
        </plugin>
        <plugin>
          <groupId>org.codehaus.mojo</groupId>
          <artifactId>build-helper-maven-plugin</artifactId>
          <version>3.4.0</version>
          <configuration>
            <portNames>
              <portName>mockcentral.port</portName>
            </portNames>
          </configuration>
          <executions>
            <execution>
              <id>reserve-network-port</id>
              <goals>
                <goal>reserve-network-port</goal>
              </goals>
              <phase>pre-integration-test</phase>
            </execution>
          </executions>
        </plugin>
        <plugin>
          <groupId>io.fabric8</groupId>
          <artifactId>docker-maven-plugin</artifactId>
          <version>0.43.0</version>
          <configuration>
            <logDate>ISO8601</logDate>
            <verbose>false</verbose>
            <!-- set to true for logging requests -->
            <showLogs>false</showLogs>
            <images>
              <image>
                <alias>mockcentral</alias>
                <name>mockserver/mockserver:5.15.0</name>
                <run>
                  <namingStrategy>alias</namingStrategy>
                  <ports>
                    <port>${mockcentral.port}:1080</port>
                  </ports>
                  <wait>
                    <http>
                      <url>http://localhost:${mockcentral.port}</url>
                      <!-- 404 means that the mockserver is running, just not accepting the request -->
                      <status>404</status>
                    </http>
                    <time>10000</time>
                  </wait>
                </run>
              </image>
            </images>
          </configuration>
          <executions>
            <execution>
              <id>start</id>
              <goals>
                <goal>start</goal>
              </goals>
              <phase>pre-integration-test</phase>
            </execution>
            <execution>
              <id>stop</id>
              <goals>
                <goal>stop</goal>
              </goals>
              <phase>post-integration-test</phase>
            </execution>
          </executions>
        </plugin>
        <plugin>
          <groupId>org.codehaus.mojo</groupId>
          <artifactId>exec-maven-plugin</artifactId>
          <version>3.1.0</version>
          <executions>
            <execution>
              <id>mockserver-config</id>
              <phase>pre-integration-test</phase>
              <goals>
                <goal>java</goal>
              </goals>
            </execution>
          </executions>
          <configuration>
            <mainClass>org.sonatype.central.publisher.plugin.mockserver.MockserverConfiguration</mainClass>
            <cleanupDaemonThreads>false</cleanupDaemonThreads>
            <arguments>
              <argument>${mockcentral.port}</argument>
            </arguments>
            <classpathScope>test</classpathScope>
            <stopUnresponsiveDaemonThreads>true</stopUnresponsiveDaemonThreads>
            <daemonThreadJoinTimeout>5000</daemonThreadJoinTimeout>
          </configuration>
        </plugin>
      </plugins>
    </pluginManagement>
    <plugins>
      <plugin>
        <groupId>com.sonatype.clm</groupId>
        <artifactId>clm-maven-plugin</artifactId>
        <executions>
          <execution>
            <goals>
              <goal>index</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.codehaus.plexus</groupId>
        <artifactId>plexus-component-metadata</artifactId>
        <executions>
          <execution>
            <goals>
              <goal>generate-metadata</goal>
              <goal>generate-test-metadata</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-plugin-plugin</artifactId>
        <executions>
          <execution>
            <goals>
              <goal>descriptor</goal>
              <goal>helpmojo</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
  <profiles>
    <!-- IT profile for running ALL ITs, will spin up docker container of mockserver, configured to respond as though
         it was central, as well as using a random port for the exposed port from the docker container -->
    <profile>
      <id>run-its</id>
      <build>
        <plugins>
          <!-- don't forget that plugin ordering is very important
               - get free port # (build-helper-maven-plugin)
               - startup mockserver docker container (docker-maven-plugin)
               - execute the java class to configure mockserver (exec-maven-pluign)
               - and finally run the ITs (maven-invoker-plugin) -->
          <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>build-helper-maven-plugin</artifactId>
          </plugin>
          <plugin>
            <groupId>io.fabric8</groupId>
            <artifactId>docker-maven-plugin</artifactId>
          </plugin>
          <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>exec-maven-plugin</artifactId>
          </plugin>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-invoker-plugin</artifactId>
          </plugin>
        </plugins>
      </build>
    </profile>
    <!-- IT profile for running only ITs that require the docker container to be running, will spin up docker container
         of mockserver, configured to respond as though it was central, as well as using a random port for the exposed
         port from the docker container -->
    <profile>
      <id>run-publish-its</id>
      <build>
        <plugins>
          <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>build-helper-maven-plugin</artifactId>
          </plugin>
          <!-- don't forget that plugin ordering is very important
               - get free port # (build-helper-maven-plugin)
               - startup mockserver docker container (docker-maven-plugin)
               - execute the java class to configure mockserver (exec-maven-pluign)
               - and finally run the ITs (maven-invoker-plugin) -->
          <plugin>
            <groupId>io.fabric8</groupId>
            <artifactId>docker-maven-plugin</artifactId>
          </plugin>
          <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>exec-maven-plugin</artifactId>
          </plugin>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-invoker-plugin</artifactId>
            <configuration>
              <pomIncludes>
                <pomInclude>publish*/pom.xml</pomInclude>
              </pomIncludes>
            </configuration>
          </plugin>
        </plugins>
      </build>
    </profile>
    <!-- IT profile for running only ITs that do NOT require the docker container to be running -->
    <profile>
      <id>run-bundle-its</id>
      <build>
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-invoker-plugin</artifactId>
            <configuration>
              <pomIncludes>
                <pomInclude>bundle*/pom.xml</pomInclude>
              </pomIncludes>
            </configuration>
          </plugin>
        </plugins>
      </build>
    </profile>
    <profile>
      <id>publish</id>
      <build>
        <plugins>
          <!-- included to disable inherited nexus-staging-maven-plugin execution -->
          <plugin>
            <groupId>org.sonatype.plugins</groupId>
            <artifactId>nexus-staging-maven-plugin</artifactId>
            <version>1.6.13</version>
            <extensions>true</extensions>
            <configuration>
              <skipNexusStagingDeployMojo>true</skipNexusStagingDeployMojo>
            </configuration>
          </plugin>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-javadoc-plugin</artifactId>
            <version>3.5.0</version>
            <executions>
              <execution>
                <id>attach-javadocs</id>
                <goals>
                  <goal>jar</goal>
                </goals>
              </execution>
            </executions>
          </plugin>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-source-plugin</artifactId>
            <version>3.2.1</version>
            <executions>
              <execution>
                <id>attach-sources</id>
                <goals>
                  <goal>jar-no-fork</goal>
                </goals>
              </execution>
            </executions>
          </plugin>
          <plugin>
            <!-- use our own just built version -->
            <groupId>${project.groupId}</groupId>
            <artifactId>${project.artifactId}</artifactId>
            <version>${project.version}</version>
            <executions>
              <execution>
                <id>deploy-artifacts</id>
                <phase>deploy</phase>
                <goals>
                  <goal>publish</goal>
                </goals>
              </execution>
            </executions>
            <extensions>true</extensions>
            <configuration>
              <publishingServerId>publisher</publishingServerId>
              <deploymentName>Central Publishing Maven Plugin - ${project.version}</deploymentName>
              <autoPublish>true</autoPublish>
              <waitUtil>published</waitUtil>
            </configuration>
          </plugin>
        </plugins>
      </build>
    </profile>
  </profiles>
</project>