Home > maven, open source, oss, software development > maven-metadata.xml generator script

maven-metadata.xml generator script

No Gravatar

As you might know we use Maven extensively. We have a corporate Maven Repository served by JFrog’s Artifactory. We have more than 30000 artifacts in our repository, – about 35GB of backup.

We try to keep up-to-date with new Artifactory releases. Unfortunately some times upgrade is not that smooth, so we need a backup and a drop-in service in case of failure.

As most of our artifacts are just old releases, we decided to create a secondary service, which acts as a drop-in service in case Artifactory is down. The idea is simple, just create a repo1.maven.org like service, with simple HTTP. Each time upgrade is to take place, copy all the new data to that repository and switch the service to point to it. – This works in case of failure too, just copy the backup to a simple “repository”.

To create the simple repository we took our Artifactory backup, removed the Artifactory specific meta-data and copied to a directory and configured an Apache HTTPD to serve it. Unfortunately the Artifactory backup contains no maven-metadat.xml, which plays key role in resolving versions. I was sure there is a maven-metadata.xml generator somewhere on the Net. But there were none! We needed it badly, so I created one. It is a simple Perl script that runs under Linux (uses shell commands extensively). It takes care of releases, but ignores SNAPSHOTs. Afterwards I realized that we need to produce md5 and sha1 checksums to, so I’ve created another script.

I thought it would be nice to share the scripts, so I’ve created a project on Google Code under maven-scripts name.

To create maven-metadata.xml:

  • cd to root of the Maven Repository folder, in my case: cd /data/mvnrepo/releases-backup
  • execute the script: /path/to/script/mvn-metadata-gen.pl

You will see 2 lines for each maven-metadata.xml generated: one for the metadata, the other for sha1.

If you need md5 and sha1 sums for POMs and JARs:

  • cd to root of the Maven Repository folder, in my case: cd /data/mvnrepo/releases-backup
  • execute the script: /path/to/script/mvn-sha1md5.pl

(Well, this could be Bash script too…)

Script could be downloaded at download page.

Please report any problem, bug, issue at projects issues page.

Lift the weight

If you have a lots of artifacts as we have, you could lift the weight a bit from your Maven Repository creating a repository as described above and setting it as a mirrored repository.

We do that, and now:

  • Artifactory eats up less Memory, CPU and disk space
  • Backup is much smaller
  • Maintenance is easier
  • Upgrades are less painful
  • Share/Bookmark

This website uses IntenseDebate comments, but they are not currently loaded because either your browser doesn't support JavaScript, or they didn't load fast enough.

  1. No comments yet.
  1. No trackbacks yet.