Creating a Maven proxy

A Maven proxy can be thought of as a Maven mirror that aggregates one or more Maven repositories.

This document will walk through the setup of maven-proxy http://maven-proxy.codehaus.org/.

Additional installation instructions can be found at http://docs.codehaus.org/display/MAVEN/MAVEN-PROXY

Aggregation of proxies may not be your friend

A word of warning. Some proxies allow to aggregate sites (ie. you can tell Maven to download from proxy X and X will check the real repositories A, B and C for the files).

In your pom you have specified the repository A and in your settings have configured A to point to your maven-proxy installation X. Because the proxy aggregates the repositories, the artifacts from the B and C repositories are available even though you have not defined them in your pom.

Normally this would not show up as an issue. The problem manifests as soon as you start using SNAPSHOT version of artifacts, perhaps as part of doing some work on maven itself. Due to the aggregation you will find that you are using SNAPSHOT versions instead of the more stable released versions.

The recommendation is to not put SNAPSHOT repositories into your maven-proxy configuration.
If you want to proxy SNAPSHOT repositories then create a separate maven-proxy installation that just
contains the SNAPSHOTS.

I think maven-proxy should have used the repository id as part of the mirror URL so that aggregation was never a side effect.

Prerequisites

Shell access to NUCLEUS

Shell access is needed to exectute commands and to configure the maven proxy. This may be done in conjunction with a sysadmin if you do not have the required privileges.

Build 0.2 of maven-proxy

See http://maven-proxy.codehaus.org/Downloads for access to http://dist.codehaus.org/maven-proxy/distributions/maven-proxy-standalone-0.2.zip

maven-proxy.properties configuration file.

Up to date configuration properties file can be found at http://maven-proxy.codehaus.org/Configuration.

An already configured instance of the maven-proxy.properties for maven-proxy 0.2 configuration file is as below.
The only changes needed are:

Install maven-proxy on NUCLEUS

Get your systems administrator to install maven-proxy.
See http://docs.codehaus.org/display/MAVEN/MAVEN-PROXY for additional instructions on how to do this.

Run maven-proxy

Run maven proxy with your maven-proxy.properties file specified.

Update settings.xml


    <mirrors>
        ...
        <mirror>
            <id>maven-proxy</id>
            <name>Maven-Proxy Mirror</name>
            <url>http://NUCLEUS:9999/repository/</url>
            <mirrorOf>central</mirrorOf>
        </mirror>
        <mirror>
            <id>maven-proxy</id>
            <name>Maven-Proxy Mirror</name>
            <url>http://NUCLEUS:9999/repository/</url>
            <mirrorOf>snapshots</mirrorOf>
        </mirror>
        <!-- Include these if you would also like to proxy internal repositories -->
        <mirror>
            <id>maven-proxy</id>
            <name>Maven-Proxy Mirror</name>
            <url>http://NUCLEUS:9999/repository/</url>
            <mirrorOf>inhouse</mirrorOf>
        </mirror>
        <mirror>
            <id>maven-proxy</id>
            <name>Maven-Proxy Mirror</name>
            <url>http://NUCLEUS:9999/repository/</url>
            <mirrorOf>inhouse_snapshot</mirrorOf>
        </mirror>
        <mirror>
            <id>maven-proxy</id>
            <name>Maven-Proxy Mirror</name>
            <url>http://NUCLEUS:9999/repository/</url>
            <mirrorOf>external_free</mirrorOf>
        </mirror>
        <mirror>
            <id>maven-proxy</id>
            <name>Maven-Proxy Mirror</name>
            <url>http://NUCLEUS:9999/repository/</url>
            <mirrorOf>external_non_free</mirrorOf>
        </mirror>
    </mirrors>




Run maven

Maven should now connect to your installed maven-proxy to download artificats.
Remember on the first run the proxy's cache will be empty so the first run will be slower than usual.

Why proxy internal repositories?

See Why proxy internal repositories