Wednesday, May 9

Convert local Maven repository into remote mirror

Almost finished my round of OSGi tutorials in Malmo, Sweden. It's been a busy time, last weekend I had two sessions back to back from 0830 to 1900! Things are a bit quieter now, so I'm going to spend time on the 0.1.5 release of Pax Construct, improving it based on feedback from the tutorials. I'm also going to add a command to create a template of a bundle that embeds a jarfile, which should make various people happy.

Anyway, on to the real topic of this post - in creating the tutorial I wrote a couple of useful scripts which let you convert your local Maven repository into a remote repository, by fixing up the necessary maven metadata and adding SHA-1 digests. You can grab the scripts from my OPS4J page at http://wiki.ops4j.org/confluence/display/~mcculls/%21sh.

I used these scripts to create an offline repository for the tutorial - by just cleaning out my local repo, running through all the exercises, copying the local repo to another location and running the scripts to add the missing metadata (see example on the !sh page). I also provided a modified settings.xml file which added mirror repos relative to the maven installation (such as file:${M2_HOME}/../../artifacts) for all the main repo ids.

This mean people could work the tutorial offline, and also meant that even when online the network wasn't hammered by everyone downloading exactly the same set of artifacts... the only downside is the extra work keeping the mirror up-to-date.

2 comments:

Peter said...

Nice work Stuart, maybe that should be part of PaxConstruct?

Anonymous said...

Thanks for your generate_maven_metadata script. However, it looks like your version of stat is different than my version. The reason being is when I run your script I get errors with the stat command. I have changed up the command to get the required timestamp.

Just a heads up.