Monday 28 March 2011

Adding additional repositories in ivy

Although I've been using ivy for quite a while, it's been pretty light touch as we had someone on the team who did all the config. Moving to another project where we're using it in a more traditional way I have started to get a bit more involved.

One of the first things we needed to do was add configuration for some more repositories. On the face of it, ivy is very well documented, but sometimes you can't see the wood for the trees (or should that be ivy :-)). I'm going to describe my understanding of the process I followed in the hope that it'll help someone else, or even that someone might comment and tell me how I could have done it much more simply.

The first part is understanding how the ivysettings.xml file works. This page shows how the default ivysettings.xml file, contained in the ivy jar file, is set up. To create your own settings, you must override the complete file in the current directory adding in all the sections contained in the original.

Starting with the original:

<ivysettings>
<settings defaultResolver="default"/>
<include url="${ivy.default.settings.dir}/ivysettings-public.xml"/>
<include url="${ivy.default.settings.dir}/ivysettings-shared.xml"/>
<include url="${ivy.default.settings.dir}/ivysettings-local.xml"/>
<include url="${ivy.default.settings.dir}/ivysettings-main-chain.xml"/>
<include url="${ivy.default.settings.dir}/ivysettings-default-chain.xml"/>
</ivysettings>

I ended up with this:

<ivysettings>
<settings defaultResolver="default" />
<resolvers>
<chain name="public">
<ibiblio name="ibiblio" m2compatible="true" />

<url name="com.springsource.repository.bundles.milestone" m2compatible="true">
<artifact pattern="http://maven.springframework.org/milestone/[organisation]/[module]/[revision]/[artifact]-[revision].[ext]" />
</url>
<url name="jboss" m2compatible="true">
<artifact pattern="http://repository.jboss.org/nexus/content/groups/public-jboss/[organisation]/[module]/[revision]/[artifact]-[revision].[ext]" />
</url>
</chain>
</resolvers>

<include url="${ivy.default.settings.dir}/ivysettings-shared.xml" />
<include url="${ivy.default.settings.dir}/ivysettings-local.xml" />
<include url="${ivy.default.settings.dir}/ivysettings-main-chain.xml" />
<include url="${ivy.default.settings.dir}/ivysettings-default-chain.xml" />
</ivysettings>

Most of the file is the same as the original except that we have overridden the public resolver chain. The original
<include url="${ivy.default.settings.dir}/ivysettings-public.xml"/>
section includes a file that looks like this:

<ivysettings>
<resolvers>
<ibiblio name="public" m2compatible="true"/>
</resolvers>
</ivysettings>

This content has been replace with an identical inline section that starts with the original ibiblio resolver and then add 2 additional Maven repos for Spring milestones and jboss.