Skip to content

Releasing an artifact to Maven Central Repo

danielpopa1986 edited this page Dec 22, 2015 · 4 revisions

Releasing an artifact to MVN Central Repository under “net.oneandone” groupId

Releasing an artifact to the Maven Central Repository there is a process that involves a couple of steps. Depending whether you want to create your own repository or use an existing one from 1&1, you can search on the Internet for the entire process or you can use some things that were already implemented inside the company. All the projects can be also found in github at https://github.com/1and1

Steps for creating a release

1. Create a Sonatype User

You need to have a Sonatype Account in order to be able to add tickets to Sonatype’s JIRA. https://issues.sonatype.org/secure/Signup!default.jspa

2. Create a new ticket to request permission to release under net.oneandone

An example of a ticket can be found at https://issues.sonatype.org/browse/OSSRH-18964

3. Generate a key that will be used to sign your artifacts

Every artifact needs to be signed. For this you can use GnuPG, for generate a key

4. Public the key to a keyserver so that anyone can download it

You can use several public keyservers to public you key. An example would be: hkp://keyserver.ubuntu.com or pgp.mit.edu To learn more about publishing a key please go to: https://help.ubuntu.com/community/GnuPrivacyGuardHowto

5. Add headers to your Java classes:

The foss-parent pom is verifying the headers from each java class inside the project. You can find the header at: https://github.com/1and1/foss-configs/tree/master/src/main/resources/net/oneandone/maven/poms/fossconfigs In license-header.txt

6. Use as parent pom in your pom.xml file the foss-parent pom from:

https://github.com/1and1/foss-parent

7. Go into your .m2 settings.xml and add the servers for releasing to Nexus:

<settings>
  <servers>
    <server>
      <id>sonatype-nexus-snapshots</id>
      <username>sonatype-user</username>
      <password>sonatype-pwd</password>
    </server>
    <server>
      <id>sonatype-nexus-staging</id>
      <username>sonatype-user</username>
      <password>sonatype-pwd</password>
    </server>
  </servers>
</settings>

8. Run mvn release:prepare

In order to prepare your release, synchronize it with the github project you will need to run mvn release:prepare Add -Dresume=false to start a fresh release and not resume an old one.

9. Run mvn release:perform

After preparing your release, you need to effectively upload it. This is done using this command. If the process success, your artifacts will be uploaded to Nexus Staging repository

10. Find your Release on the Nexus staging repository

Go to Sonatype Nexus repository (https://oss.sonatype.org/#welcome), find your artifact, close it, test it, and after that release it to the Central Repository. Close and release staging repository: https://oss.sonatype.org/index.html#stagingRepositories

Usefull resources