Friday, November 21, 2008

Installing Archiva

Archiva is an open-source proxy for Maven. It allows you to create an internal repository for your company that you can back up or check in, and makes downloads of dependencies much faster. This is how I installed it.

As of the time of writing, the current version is 1.1.3. Using a browser, I first downloaded the WAR distribution to a CentOS box. I tried to deploy it in tomcat 6.0.18, first running under the default version of java, which was 5, then under java 1.6.0_10. Unfortunately, despite following all the tomcat-specific instructions, it wouldn't run, so I downloaded the standalone distribution instead.

I couldn't run the standalone distribution either, until I installed java 6. To uninstall the default jdk:

$ yum remove java

I downloaded and ran jdk-6u10-linux-i586-rpm.bin from This installs Java 6.

Having downloaded (the standalone distribution), I unzipped it to /opt, then ran /opt/apache-archiva-1.1.3/bin/archiva.

In our case, we created the DNS name "repo" for the box. So the app was visible at http://repo:8080/archiva/.

I then needed to point my maven builds at the new repository. On my development machine, I created settings.xml (see below) in <maven home>, which in my case is ~/.m2. This tells maven to use our internal repo as the proxy for all downloaded artifacts (the line <mirrorOf>*</mirrorOf>). This can be changed to limit the set of artifacts for which you want to use archiva.


To prime the archiva repository, I removed everything in my local repository (~/.m2/repository) and did a clean build. Archiva automatically downloads and stores the artifacts in /opt/apache-archiva-1.1.3/data/repositories/internal, which you can back up, or check in, if you are paranoid about such things. You can then browse to see what was downloaded at http://repo:8080/archiva/browse.

I then provided all our developers with the settings.xml file, and I was done. Note: you can forgo settings.xml and instead put the same info in your pom.xml files, but this way the pom.xml files are more portable and isolated from the corporate repository.

1 comment:

Martin Gladdish said...

Thanks, I'd just run across this problem and Archiva's documentation refuses to tell me what version of Java it depends upon.