Monday, June 2, 2008

Maven 2 and Apache Archiva

Recently I've started to use Archiva as a Maven 2 repository and I had this unexpected behaviour when using it. First of all I've configured a profile in /home/mpigulski/.m2/settings.xml and added there a repository that was pointing to my Archiva repository. It was working fine, but every time the central repoistory was looked up then my Archiva server was skipped in the path and the whole idea of Archiva as a Maven 2 repository proxy was missed.

I've started digging again and found this configuration option.

After adding this to my settings.xml looked something like this:

<settings>
...
<mirrors>
<mirror>
<id>internal</id>
<name>Internal Mirror of http://repo1.maven.org/maven2/</name>
<url>http://archiva:8001/archiva/repository/internal/</url>
<mirrorof>central</mirrorof>
</mirror>
</mirrors>
...
</settings>


After this, every call to the central repository is overriden by this mirror configuration and every jar downloading is performed very fast.

5 comments:

Brian Fox said...

You should take a look at Nexus, since you would be able to group all your repositories into a single logical group with a single mirror setting in Maven. This will be even faster since Maven will need to make just one request to Nexus to find any artifact...as opposed to making a call to each repo.

Maciej Pigulski said...

If I'm not mistaken Archiva works in the same pattern as you describe, Brian. When I've set up Archiva as the central repository mirror maven calls only this repository and Archiva checks out any external (remote) repositories that it has configured to use (i.e. ibiblio, etc.).<

Anyway I will take a look at Nexus, it's always good to know more, thanks :)

Brian Fox said...

I'm pretty sure that Archiva doesn't yet support logically grouping more than one repo (ie central + java.net+ your internal repos) into a single logical URL. You need to configure a separate entry for each repo and Maven makes a separate request.

FWIW, Artifactory also allows logical grouping like Nexus.

Maciej Pigulski said...

I had to look upon Nexus to understand what do you mean. I've found that Nexus uses groups to create single URLs. In Archiva there is a similiar solution called Proxy Connectors. You create a single internal repository and some links to remote repositories, for instance, and then you add Proxy Connectors that connect your internal repository with those remote ones. The drawback of this solution is the fact that you have all the jars (from many remote repositories) physically in a single repository location and the configuration is less flexible than in Nexus.

david santos said...

Hello, Maciej!
I loved this post and this blog.
Happy day