How do I use Archiva as a mirror of the maven central repository?
Author: Deron Eriksson
Description: This tutorial describes how to use Archiva as a mirror of the maven central repository.
Tutorial created using: Windows Vista || JDK 1.6.0_04 || Eclipse Web Tools Platform 2.0.1 (Eclipse 3.3.1)

In another tutorial, we saw how to install and run the standalone distribution of ArchivaS. By default, Archiva comes with a proxy to the mavenSW central repository. Therefore, it's basically all set up to be used as a mirror of the maven central repository. If we make a request of Archiva for an artifact for a central repository artifact, it will download that artifact and return that artifact to us. If we make future requests for that artifact, Archiva will return to us the copy of the artifact that it had already downloaded from the central repository.

Let's try this out. To do this, in our settings.xml file we need a "mirror" entry that points to the URL for our Archiva repository. The mirrorOf element specifies "central", the super pomW id for the maven central repository. I'll call this mirror "archiva.central", since this is an archivaS mirror of the central repository.

archiva mirror of the maven central repository from settings.xml


Now, I'll add a new dependency to my "mytest" project. I'll add version 2.3 of the "commons-lang" dependency.

Adding the "commons-lang" dependency to pom.xml


My updated pom.xml file (with the commons-lang dependency) is shown here:


<project xmlns="" xmlns:xsi=""

Now, I'll run the maven "eclipse:eclipse" goal on the "mytest" project:

Executing 'mvn eclipse:eclipse' on 'mytest' project

The console output from "mvn eclipse:eclipse" on "mytest" is shown here:

Console output from 'mvn eclipse:eclipse'

[INFO] Scanning for projects...
[INFO] Searching repository for plugin with prefix: 'eclipse'.
[INFO] ------------------------------------------------------------------------
[INFO] Building mytest
[INFO]    task-segment: [eclipse:eclipse]
[INFO] ------------------------------------------------------------------------
[INFO] Preparing eclipse:eclipse
[INFO] No goals needed for project - skipping
[INFO] [eclipse:eclipse]
10K downloaded
... [cut for clarity]
239K downloaded
[INFO] Using source status cache: C:\dev\workspace\mytest\target\
[INFO] Not writing settings - defaults suffice
[INFO] File C:\dev\workspace\mytest\.project already exists.
       Additional settings will be preserved, run mvn eclipse:clean if you want old settings to be removed.
[INFO] Wrote Eclipse project for "mytest" to C:\dev\workspace\mytest.
[INFO] ------------------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 4 seconds
[INFO] Finished at: Thu Feb 07 09:47:37 PST 2008
[INFO] Final Memory: 3M/7M
[INFO] ------------------------------------------------------------------------

Notice in the console output that the common-lang pom and jarW files were downloaded to our local maven repository from our Archiva mirror rather than from the central repository.

If we browse Archiva, we can see that commons-lang has been added to the Archiva repository.

commons-lang 2.3 added to Archiva repository

Easy, huh?