Saturday, June 14, 2025

Using the maven-release-plugin with the Central Portal

I have my Jinq Java library published in the Maven Central repository that everyone uses for publishing their libraries. Back when first started publishing the library, I used the maven-release-plugin for Maven to do the actual releasing of my code into Maven. The plugin was nice because it was an all-in-one plugin that automatically packaged up Java code and ensured all the extra artifacts were present before uploading things, and I then only needed to go to the oss.sonatype.org Nexus Repository Manager to click a few buttons to approve the release of my library to Maven Central. I've never been too familiar with Maven or what the maven-release-plugin was doing, but it worked, so I was happy.

Now Sonatype has deprecated the old workflow and wants people to move to their new Central Portal to publish things to Maven Central. And looking through the documentation on how to use the Central Portal, it seems like Sonatype has been moving away from all-in-one publishing scripts. Instead, their documentation seems to describe how to cobble together separate plugins to package everything together, resulting in a fully customizable approach to publishing a library. In particular, they recommend using their new central-publishing-maven-plugin for uploading libraries to the Central Portal, but this Maven plugin only does the deployment. It doesn't do anything with preparing and packaging your library to be uploaded. So it was not clear how to move from using the maven-release-plugin that does everything to using this central-publishing-maven-plugin which only does the upload part.

Fortunately, it turns out the two plugins are compatible. If you already have a working maven-release-plugin workflow, then you just have to add the central-publishing-maven-plugin to the Maven build files. The central-publishing-maven-plugin will extend the existing deploy code to support deploying to the new Central Portal, and when you run the maven-release-plugin, it will automatically use the central-publishing-maven-plugin to do the upload. I'm sure that was all probably obvious to Maven experts, but the whole reason I was using the maven-release-plugin was that I wasn't a Maven expert so I was unclear on how to cobble together all the necessary plugins together properly in Maven. So that's great. If you're using the maven-release-plugin, then migrating to the new Central Portal simply involves adding a new plugin to your Maven build.