Skip to content

Maven Central: Deploy Process

Siddharth Kothari edited this page Jul 26, 2019 · 2 revisions

We use Sonatype for releasing the artifacts. Follow the guide at https://central.sonatype.org/pages/ossrh-guide.html for the overview.

Steps

  1. Create a settings.xml file of the following format:
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0">
  <servers>
    <server>
        <id>ossrh</id>
        <username>{username}</username>
        <password>{password}</password>
    </server>
  </servers>
</settings>
  1. Create a GPG key and distribute it to public key servers. Read more here - https://central.sonatype.org/pages/working-with-pgp-signatures.html.

  2. Perform the release with the following command:

mvn release:perform -Darguments=-Dgpg.passphrase=${gpg_passphrase} -s /path/to/settings.xml

Things to keep in mind while performing the release:

  • The pom.xml in origin HEAD should point to the release candidate version (whether it's x.y.z or x.y.z-SNAPSHOT)
  • mvn release:clean release:prepare command will create the release.properties file necessary for performing the release with the above command. It will also push the relevant tags to the Github repo based on the latest HEAD commit.
  • Finally, the release:perform command will take into account the tag present in the release.properties file.

An example release.properties file looks like:

#release configuration
scm.tagNameFormat=@{project.artifactId}-@{project.version}
scm.tag=1.2.0
pushChanges=true
scm.url=scm\:git\:git@github.com\:appbaseio/appbase-droid.git
preparationGoals=clean verify
project.scm.io.appbase\:appbase-droid.tag=HEAD
project.scm.io.appbase\:appbase-droid.connection=scm\:git\:git@github.com\:appbaseio/appbase-droid.git
project.scm.io.appbase\:appbase-droid.url=git@github.com\:appbaseio/appbase-droid.git
project.rel.io.appbase\:appbase-droid=1.2.0
project.scm.io.appbase\:appbase-droid.developerConnection=scm\:git\:git@github.com\:appbaseio/appbase-droid.git
remoteTagging=true
scm.commentPrefix=[maven-release-plugin] 
project.dev.io.appbase\:appbase-droid=1.2.2-SNAPSHOT
exec.snapshotReleasePluginAllowed=false
completedPhase=end-release

Clone this wiki locally