Maven Proxy


One of the important pieces of the pie you will need when using Maven2 in your organization is Maven Proxy. Let me explain what this magnificent piece of software is. It is a partially documented masterpiece that will implements a shared repository for all team members and collaborators using maven. Lets face it. If you have about five or six developers each using Maven then you have the bandwidth required to load a local repository times five or six. Instead you can setup Maven proxy in an existing web container like Tomcat or Jetty or launch it from the command line and it will act like the Ibiblio repository. It downloads artifacts on the fly as needed from the official Ibilio Maven2 repository and caches them on disk for all team members to share. The biggest problem, for me at least, was setting it up. The first time I tried failed because we sit behind an authenticating HTTP proxy and I wasn’t exactly clear on how to get Maven Proxy to talk through it. Well after chatting on the #Maven #IRC channel I really got discouraged. Apparently nobody there at the time had experience with setting up Maven Proxy over the Ibilio M2 repository. I almost threw in the towel on Maven2 altogether until I hit the Maven mailing list with my problems. After a few exchanged emails with one particularly helpful person I was all set up and running Maven Proxy for my team here. I haven’t had any problems since (though there is this existing issue with retrieving the assembly plugin but I attribute that to the codehaus outage issue). So my purpose today is to introduce you to what I feel is a common problem with configuring Maven proxy.

Maven Proxy and HTTP proxy authentication

The most important thing you need to download after downloading Maven Proxy is the config file. (I’m not sure why it’s not included in the bundle for Maven-proxy but go figure.) You’ll want the 0.2 version. Towards the bottom of this file you will see a section outlining a list of proxies. It looks like you can actually configure a separate proxy for each repo though you’ll most likely need to configure only one for all repos as I did. There is a proxy.list property with a comment that I just figured out two seconds ago. (Honestly I couldn’t understand what it meant by auto discovering the proxies but now I see that it is the authors intention to not need the proxy.list property.) Each entry in the comma delimited list should point to a group of properties beggining proxy.<entry-name> defining the attributes for that proxy. Now here’s the tricky part that got me and at least one other fellow. For each repository defined below the list of proxies there is an optional property pointing to which proxy it should use. See my partial config listing here as an example:

################ PROXIES
#This is just a hack, it should auto discover them
proxy.list=instagate

#Authenticated proxy
proxy.instagate.host=&lt;our-proxy-IP&gt;
proxy.instagate.port=8080
proxy.instagate.username=nottelling
proxy.instagate.password=dontneedthatinfoeither

################# REPOSITORIES
#This is not just a hack, it specifies the order repositories should be checked
#Note that the proxy adds a "/" which is why the urls aren't suffixed with a "/"
repo.list=local-repo,www-ibiblio-org,dist-codehaus-org

#local-store
# The local store represents a location that local jars you host can be located.
# This could also be achieved by having a local http repository, but this is less cumbersome
repo.local-repo.url=file:///./maven/repo-local
repo.local-repo.description=Neware In-office Maven Repository
#If copy is true, jars are copied from the store to the proxy-repo. Only configurable for file:/// repos
repo.local-repo.copy=false
#If hardfail is true, any unexpected errors from the repository will cause
#the client download to fail (typically with a 500 error)
repo.local-repo.hardfail=true
#Don't cache a file repository
repo.local-repo.cache.period=0

#www.ibiblio.org
repo.www-ibiblio-org.url=http://www.ibiblio.org/maven2
repo.www-ibiblio-org.description=www.ibiblio.org
repo.www-ibiblio-org.proxy=instagate
repo.www-ibiblio-org.hardfail=false
#Cache this repository for 1 hour
repo.www-ibiblio-org.cache.period=3600
repo.www-ibiblio-org.cache.failures=true

#dist.codehaus.org
repo.dist-codehaus-org.url=http://dist.codehaus.org
repo.dist-codehaus-org.proxy=instagate
repo.dist-codehaus-org.hardfail=false
repo.dist-codehaus-org.cache.period=3600
repo.dist-codehaus-org.cache.failures=true

These are the most important properties to set in this file along with the first property listed at the top. (The first property defines where the cache is stored.) You’ll see in my above example how I define a proxy named instagate (that’s the internet appliance we use as our HTTP proxy/gateway) and then reference the proxy by name in the definitions for each repository.

I hope that clears things for at least one other person struggling to get Maven-proxy working. I just realized something. I typically try to be funny during my post to keep readers interested yet the above text has not even a speck of humor. Purple monkey! Purple monkey! Purple monkey! Wasn’t that funny? Not to me either. I must be losing my touch. Maybe next time I’ll joke more. Until later, holla at me…

6 thoughts on “Maven Proxy

  1. It would be a great help if you can post your complete properties file for maven proxy or email it to me.Another thing i want to know is how u define the repositort in your pom or settings.xml (which one u use settings.xml or directly in pom) and also maven proxy say sth abt ~/build.properties what extaclty it is . Waiting for u r reply thanx in advance

  2. All this plus tons of new armor and weapons, a complete treatment of firearms in the Pathfinder RPG, a vast array of martial arts, finishing moves, vehicle combat, duels, and new combat-oriented spells for every spellcasting class in the game.
    As the Japanese Imperial Army rolls across China, documented facts
    and fantasy intermingle in the breathtaking exploration of alternative history that is NIGHT RAID 1931
    – The Complete Collection. They decide to enlist the help of the French in order to
    dethrone King John but they need to bide some time to negotiate with the French.

Leave a reply to Proxy List Cancel reply