Releasing to Kenai via Maven

Ever since the website feature appeared on Kenai I’ve been trying to get releases to work using it to host the maven repository. Although it works, it’s always had the odd issue where whilst uploading artifacts to the repository, the connection would timeout causing the release build to fail.

For small projects this isn’t really a problem, but for some of mine this is an issue to either the number of artifacts present (retepXMPP currently has over a hundred) we can’t have the release build to fail part way through leaving both the mercurial and maven repositories in an inconsistent state.

The retepMicroKernel project is further complicated by the fact that it has native code – so a release has to be performed in parts with the native code built on the respective platforms.

Fortunately there is a solution to this – perform the release build into a staging repository then once it’s complete merge that repository with the public one. This also means we can perform a release and if something horrible goes wrong we just redo the release without the public seeing the failed release.

Fabrizio Giudici also found this solution with an additional benefit. The maven release process makes several commits into the repository, but as mercurial is a distributed scm we can use that to our advantage – if the release build fails it doesn’t cause issues remotely with having to remove tags etc (which I’ve done before).

So here’s what I did when releasing version 9.11 of retepTools this week, first I followed Fabrizio’s suggestions for configuring the root pom.xml file.

Then I created a temporary directory and inside that clone the public mercurial repo then make a clone of the clone:

# The maven staging repository
mkdir -p ~/tmp/stagingrepo

# The staging mercurial repository - this is a clone of the public repository
cd ~/tmp
hg clone https://hg.kenai.com/hg/reteptools~hg reteptools-stage

# The release mercurial repository - this is the one we will run maven against
# it is a clone of the staging repository
hg clone reteptools-stage reteptools

Now we run the release process:

cd ~/tmp/reteptools
mvn --batch-mode \
       -Dstaging.hg.repo.url=~/tmp/reteptools \
       -Dstaging.mvn.repo.url=file:///Users/peter/tmp/stagingrepo \
       -DreleaseVersion=9.11 \
       -DdevelopmentVersion=9.12-SNAPSHOT \
       -Dtag=retepTools-9.11 \
       release:prepare release:perform

Maven will now perform the release, making commits into the ~/tmp/reteptools repository and pushing them to ~/tmp/reteptools-stage.

Once we are happy that the release is clean we make it public. First mercurial – we need to push the changes back to kenai:

cd ~/tmp/reteptools-stage
hg push

Next the artifacts:

# A temporary directory for maven - it will not run without this directory
mkdir -p tmpdir
mvn org.codehaus.mojo:wagon-maven-plugin:1.0-beta-2:merge-maven-repos \
  -Dwagon.source=file:///Users/peter/tmp/stagingrepo/ \
  -Dwagon.target=dav:https://kenai.com/website/reteptools/maven/releases/ \
  -Dwagon.targetId=retep.releases \
  -Djava.io.tmpdir=target

[Edited to fix a couple of errors in the maven commands]

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s