Maven deployment to Maven central

It feels really good to see the locally built and signed artifacts on maven central and it’s not a big problem to get this work ….. if you know how 😉

The main issues are to define scm and distributionManagement inside pom.xml so it’s easy to build and release via maven-release-plugin and to sign them (previously created gpg keypair needed) using maven-gpg-plugin.

There is no need to define maven-gpg-plugin inside your pom but it’s important that you use oss-sonatype’s parent pom.
To release a new version of the project all I have to do is t call

mvn release:perform

mvn release:prepare -Darguments=”-Dgpg.keyname=C156CAD5 -Dgpg.passphrase=\”myGpgPassphrase\””
mvn release:perform -Darguments=”-Dgpg.keyname=C156CAD5 -Dgpg.passphrase=\”myGpgPassphrase\” -Psonatype-oss-release”

 

release:perform automatically uploads the artifacts to the staging repository oss.sonatype.org, the credentials have to be defined inside ~/.m2/settings.xml

 

A great step-by-step documentation can be found here.

 

PS: The pom.xml can be found here

PPS: The released project is durationformatter

Advertisements
This entry was posted in Java, Tips. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s