Joe DiNottra
Joe DiNottra

Reputation: 1008

How to combine the Maven Release Plugin with Nexus Staging Plugin?

I'm releasing an open source project to Maven Central, and I wanted to combine the Maven Release Plugin with the Nexus Staging Plugin, but don't know how.

The Maven Release Plugin performs all I need:

All this automation means I can perform a release with a single command line. Awesome.

The only caveat here is that the deploy task above merely delivers the JARs to Maven Central Repository, but does not publish them. I still need to log in to the Maven Central web site, find the release, click on "Close"... wait a few minutes... not ready yet... wait a couple of minutes... check again... oh, it's ready... finally click on "Release". I don't like this manual, error-prone task.

The Nexus Staging Plugin, on the other hand, does the "Close" + "Release" automatically. However, it doesn't do anythine else, like the list of steps described above.

Is there any way I could replace the "deploy" section above with the "Nexus Staging Plugin" instead?

Upvotes: 2

Views: 1759

Answers (1)

Joe DiNottra
Joe DiNottra

Reputation: 1008

How silly of me. It's incredible how closer you get to an answer when you go through the process of formulating the question.

The solution was very simple. Just by adding the Nexus Staging Plugin to the pom.xml automatically replaces the default "deploy" step.

This is my pom.xml section for the Nexus Staging Plugin:

  <!-- Nexus Staging -->

  <plugin>
    <groupId>org.sonatype.plugins</groupId>
    <artifactId>nexus-staging-maven-plugin</artifactId>
    <version>1.6.7</version>
    <extensions>true</extensions>
    <configuration>
      <serverId>ossrh</serverId>
      <nexusUrl>https://oss.sonatype.org/</nexusUrl>
      <autoReleaseAfterClose>true</autoReleaseAfterClose>
    </configuration>
  </plugin>

Nothing special, as you see. With this, calling the Maven Release Plugin automatically uses the Nexus Staging Plugin, instead of the default deployment.

$ mvn -B release:prepare && mvn release:perform

Fully automated from beginning to end: Git release + Maven Central publishing in one go.

Cheers!

Upvotes: 1

Related Questions