Using the Proximity Maven Repo Cache/Proxy

Posted by: Bruce Snyder on January 29, 2008



Recently I got frustrated with the latency of accessing Maven remote repositories, so I sought a solution. What I found was Deng Ching's blog entry titled The Hype About Repository Managers. Somehow I wound up downloading Proximity and what I discovered made me very happy.

Proximity is somewhere between a Maven artifact cache and a Maven repo proxy. It runs as a web application locally and by pointing Maven at the local URL for the web app, Maven will look up dependencies for any given project build using Proximity. If the Proximity cache doesn't contain a dependency, Proximity does the work to fetch that dependency from a remote repo and stuffs it in its cache. So the first build when using Proximity is slow becuase it's propulating its cache with artifacts but subsequent builds are damn fast.

Upon first downloading Proximity, I dug through the docs trying to figure out how to add another repository and I couldn't find anything. So I pinged Tamás Cservenák, the creator of Proximity, via IRC for some assistance and he was incredibly helpful in working with me to accomplish this task (thanks again, Tamás!).

To add another Maven repo to Proximity, I had to edit the proximity.properties file to create another FSStorage.baseDir, the proximityRepositories.xml file to add new LogicDrivenRepositoryImpl, WritableFileSystemStorage and CommonsHttpClientRemotePeer bean definitions for the new repo and the proximityContext.xml file to add point to the LogicDrivenRepositoryImpl bean definition. Next, I had to tell Maven to use Proximity as a mirror of everything by adding the following mirror definition to the ~/.m2/settings.xml file for Maven:


<mirror>
<id>Proximity</id>
<name>Proxmity mirrored central.</name>
<url>http://localhost:8080/proximity/repository/public</url>
<mirrorOf>*</mirrorOf>
</mirror>


This tells Maven to look at the local Proximity URL for all artifacts and at that point, Proximity takes over. I've made available a ZIP archive of Proximity with my edits if you're interested. Using what I configured is as easy as downloading it, running it using the included jetty.sh script and editing your settings.xml file using the mirror config above. Then move aside your own local Maven repo so that a new one will be created.

In using Proximity so far, I've found that letting it spawn HTTP connections to download artifacts seems to be far more efficient that Maven. Chris started using Proximity and we're no longer seeing a huge amount of open sockets from downloading artifacts. So now I'm curious to peek at the Proximity source to see how this is being handled.

Also, Proximity is being adopted by Sonatype and it will be known as Nexus. For more info, see Jason's blog entry titled, Proximity Lives on as Nexus for Maven Users.
Bruce Snyder

About Bruce Snyder

Bruce Snyder has a unique skill set with a deep background in software architecture and engineering and the ability to liaise with the business side. With nearly 20 years of professional experience in enterprise and open source software, Bruce has a passion for creative problem solving, a strong work ethic and the ability to bridge the gap between business leaders and software development teams.

Bruce is a member of the Apache Software Foundation and has worked on several Apache projects. He has also authored books on Apache ActiveMQ, the Spring Framework, Apache Maven and Apache Geronimo, spoken at numerous software conferences and has helped to build communities around open source software.