Skip to content

How To Publish To The Maven Repo

ryanlchandler edited this page Sep 23, 2020 · 4 revisions

Prerequisites

1. You must have a credentials for https://oss.sonatype.org

2. You must have GPG installed and setup with a private key

3. You must have Maven installed

4. You must have Java installed

Steps

1. Login to sonatype.org

2. Under your profile in sonatype.org generate a user access token

3. Edit ~/.m2/settings.xml and add the xml provided when you created your user access token

<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
                          https://maven.apache.org/xsd/settings-1.0.0.xsd">
   <localRepository/>
   <interactiveMode/>
   <offline/>
   <pluginGroups/>
   <mirrors/>
   <proxies/>
   <profiles/>
   <activeProfiles/>
   <servers>
      <server>
         <id>sonatype-nexus-staging</id>
         <username>***</username>
         <password>*****</password>
      </server>
   </servers>
</settings>

* make sure you update the <server><id>...</id></server> to the one shown above

4. Verify your maven setup

mvn help:effective-settings

* You should see the server settings you just added

5. export GPG_TTY=$(tty)

6. Build and deploy the JAR

mvn clean deploy -DskipTests=true

* You'll be prompted to enter the password for your private key

7. Release

In sonatype click "Staging Repositories", select the highest numbered repo, and click the "Release" option.