Skip to main content
Last updated June 28, 2011 09:22, by juven
Feedicon  

Java.net Maven Repository Usage Guide


Introduction

Java.net uses Sonatype Nexus to provide Maven repository hosting service: https://maven.java.net. You can deploy snapshots, stage releases, and promote your releases so they will be synced to Maven Central. To assure the quality of artifacts in Maven Central, all new release versions must meet some quality requirements. Once you have new a release version deployed to Nexus repository, we will help you clean up old versions and sync them into central. This document will guide you the whole process step by step.


Create a JIRA Ticket

Go to http://java.net/jira/browse/MAVEN2_REPOSITORY and create a ticket with:

  • Summary: project name
  • Component: migration-cleanup
  • Description:
    • your java.net project url (mandatory). If your project is not hosted on java.net, please use Sonatype OSS Repository.
    • groupId (mandatory)
    • artifactId
    • scm url

We will review the ticket and prepare Nexus repository and update ticket if everything is ok.


Repositories

URL purpose
https://maven.java.net/content/repositories/snapshots/ repository for deploying snapshots
https://maven.java.net/service/local/staging/deploy/maven2/ repository for deploying releases only
https://maven.java.net/content/repositories/releases/ repository for staging promotion/release, this repository is synced to Maven Central
https://maven.java.net/content/groups/public/ repository group for browsing or downloading snapshots and releases


Prerequisites and Requirement

Please make sure you read these 2 documents before going on:


Prepare PGP Environment

Since all artifacts synced to Maven Central must be PGP signed, so if you don't have a basic PGP environment , you will need to prepare it before moving on. This includes:

  • Install GnuPG
  • Generate a key pair
  • Distribute the public key to a key server

Please walk through this document for the details.


Deploy Snapshots and Stage Releases with Maven


POM Configuration

To save your configuration, we provide a java.net parent POM which you can configure your POM to inherit from:

Note that this is not a requirement. If you want, you can always copy the configurations in the parent POM and paste to your own POM.

<project>
  ...
  <parent>
    <groupId>net.java</groupId>
    <artifactId>jvnet-parent</artifactId>
    <version>1</version>
  </parent>
  ...
</project>

Now you need to configure your POM's SCM element like this: (for svn,git,hg users respectively)

<!-- Subversion -->
<project>
  ...
  <scm>
    <connection>scm:svn:http://svn.java.net/svn/foo~svn/trunk</connection>
    <developerConnection>scm:svn:https://svn.java.net/svn/foo~svn/trunk</developerConnection>
    <url>http://java.net/projects/foo/sources/svn/trunk/show</url>
  </scm>
  ...
</project>

Note that If you don't use the standard svn layout , you must configure tagBase of maven-release-plugin.


<!-- Git -->
<project>
  ...
  <scm>
    <connection>scm:git:git@github.com:juven/git-demo.git</connection>
    <developerConnection>scm:git:git@github.com:juven/git-demo.git</developerConnection>
    <url>git@github.com:juven/git-demo.git</url>
  </scm>
  ...
</project>


<!-- Mercurial -->
<project>
  ...
  <scm>
    <connection>scm:hg:http://bitbucket.org/juven/hg-demo</connection>
    <developerConnection>scm:hg:https://bitbucket.org/juven/hg-demo</developerConnection>
    <url>http://bitbucket.org/juven/hg-demo</url>
  </scm>
  ...
</project>

Note that you need to store your HTTP login so hg push will not ask for it from command line. Edit .hg/hgrc like this:

[auth]
hg-demo.prefix = https://bitbucket.org/juven/
hg-demo.username = juven
hg-demo.password = ******
Or, more securely, use: http://pypi.python.org/pypi/mercurial_keyring

Settings.xml Configuration

You need to configure your java.net credential in ~/.m2/settings.xml:

<settings>
  ...
  <servers>
    <server>
      <id>jvnet-nexus-snapshots</id>
      <username>your-java.net-id</username>
      <password>your-java.net-pwd</password>
    </server>
    <server>
      <id>jvnet-nexus-staging</id>
      <username>your-java.net-id</username>
      <password>your-java.net-pwd</password>
    </server>
  </servers>
  ...
</settings>

POM Cleanup

  • remove extension org.jvnet.wagon-svn:wagon-svn, https://maven.java.net is based on http so this extension is no longer needed.
  • remove repositories element, all your dependencies should be already in central and you will be synced to central as well.
  • remove pluginRepositories element, all the plugins you use should be already in central.
  • remove distributionManagement element, it's already declared in jvnet-parent POM.


Publish Snapshots

see https://docs.sonatype.org/display/Repository/Publish+Snapshots

Stage a Release

see https://docs.sonatype.org/display/Repository/Stage+a+Release


Deploy Snapshots and Stage Releases with Ant

see https://docs.sonatype.org/display/Repository/Deploy+Snapshots+and+Stage+Releases+with+Ant, and with


Release It!

You will first need to close and release your staging repository: (all the steps below require you log into https://maven.java.net UI with your java.net credential)

Once staging release is done, your released artifacts will be synced to Maven Central. The sync script runs every 4 hours.


Clean Up Old Versions

Only when you have your latest version deployed to new Nexus repository, will we clean up the old versions and sync them to Maven Central.

Please comment on your JIRA ticket and we will review the old versions. If serious problems were found, like broken POM, empty JAR, we will need your help to fix them first. After that, these artifacts will be moved to new Nexus repository and synced to Maven Central.

Please stop deploying artifacts to old java.net maven repository, we only clean up your artifacts in old repository once.


Help

 
 
Close
loading
Please Confirm
Close