Publish Java Artifacts to Maven Central

Register Domain with Sonatype

GNU Privacy Guard

gpg2 --gen-key
$ gpg2 --list-keys/Users/zteater/.gnupg/pubring.kbx
---------------------------------
pub rsa2048 2020-09-04 [SC]
CBD4A688527344A89DA698A667E4BA1596973688
uid [ultimate] Zack Teater <zteater@gmail.com>
sub rsa2048 2020-09-04 [E]
$ gpg2 — keyserver hkp://pool.sks-keyservers.net — send-keys CBD4A688527344A89DA698A667E4BA1596973688

Configure Maven Password Encryption

$ mvn --encrypt-master-password
{foaG444L5k8HfeBBQJ9CPwoInd52AZ58HBJQ9Xha/04=}

Note: You can pass a plain-text password as an argument to this command, however this is not recommended since the command will be stored in history.

Note: If the master password is changed, other encrypted passwords must be re-encrypted.

Configure settings.xml with Nexus Login

$ mvn --encrypt-password
$ {Qet4qKbuSQYHJh3YprA/kgfG40fD/ki+U9TRy/+oltk=}

Note: If your Nexus password changes, you will need to re-encrypt this value.

Note: The repository.id must match the server.id

Configure pom.xml with Artifact Details

Configure pom.xml for Release

Publish to Maven Central

mvn build-helper:parse-version versions:set -DnewVersion=\${parsedVersion.majorVersion}.\${parsedVersion.minorVersion}.\${parsedVersion.nextIncrementalVersion} versions:commit
mvn deploy
Maven Central extracts meta-data from your pom.xml to populate the artifact details page.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Zack Teater

Zack Teater

I am a Java architect currently working at CapTech Consulting. I enjoy developing web applications and integrating enterprise systems.