Using Ivy with Springs repository and other Maven repositories

We use Apache Ivy in the office now and I thought I’d give it a proper whirl at home. In the office we have our repository to store all the libraries we have in our environment and so the setting up of resolvers etc is all taken care off. Out in the real world you need to do this yourself, but the beauty of Ivy is its simple. First up I’m using Eclipse 3.4 with the IvyDE plugin. With those installed I created a new Java Project and then set about creating my ivy.xml. For this project there are a few requirements I wanted.

  1. I want to use Spring for config
  2. I want to have a play with Compass – the lucene abstraction

Out of the box Ivy will use the “ibiblio” resolver which makes use of the Ibiblio’s Maven repository. This is not really the greatest starting point as its not so easy to find stuff in. Spring however have their own repository with a lot of open source libraries and is much easier to search http://www.springsource.com/repository/app/. So my ivy.xml file looks like:

< ?xml version="1.0" encoding="ISO-8859-1"?>
<ivy -module version="2.0">

	<info organisation="matt" module="compassTest" status="integration"></info>

	<dependencies>
		<dependency org="org.springframework" name="org.springframework.context.support"
			rev="2.5.6.A"></dependency>
		<dependency org="org.compass-project" name="compass" rev="2.2.0-M2"></dependency>
	</dependencies>

</ivy>

Very simply I want to use Springs context support classes and I want to have play with Compass. In order to get this all to work I needed to create my own ivy-settings.xml with some new resolvers. First I need to add Springs repository resolvers (Doc’d here), then I need to add Compass’s Maven repo and finally Compass depends on a version of Lucene not in Springs repository so I need to add in ibiblio’s Maven2 repository. My final ivy-settings.xml file looks like:

< ?xml version="1.0" encoding="ISO-8859-1"?>
<ivysettings>
	<settings defaultResolver="spring.compass.ibiblio" checkUpToDate="true"></settings>
	<resolvers>
		<chain name="spring.compass.ibiblio">
			<url name="com.springsource.repository.bundles.release">
				<ivy pattern="http://repository.springsource.com/ivy/bundles/release/&#91;organisation&#93;/&#91;module&#93;/&#91;revision&#93;/&#91;artifact&#93;-&#91;revision&#93;.&#91;ext&#93;"></ivy>
				<artifact pattern="http://repository.springsource.com/ivy/bundles/release/&#91;organisation&#93;/&#91;module&#93;/&#91;revision&#93;/&#91;artifact&#93;-&#91;revision&#93;.&#91;ext&#93;"></artifact>
			</url>
			<url name="com.springsource.repository.bundles.external">
				<ivy pattern="http://repository.springsource.com/ivy/bundles/external/&#91;organisation&#93;/&#91;module&#93;/&#91;revision&#93;/&#91;artifact&#93;-&#91;revision&#93;.&#91;ext&#93;"></ivy>
				<artifact pattern="http://repository.springsource.com/ivy/bundles/external/&#91;organisation&#93;/&#91;module&#93;/&#91;revision&#93;/&#91;artifact&#93;-&#91;revision&#93;.&#91;ext&#93;"></artifact>
			</url>
			<ibiblio name="compass" m2compatible="true" root="http://repo.compass-project.org"></ibiblio>
			<ibiblio name="ibiblio" m2compatible="true"></ibiblio>
		</chain>

	</resolvers>
</ivysettings>

After plugging the above into Eclipse and setting up my IvyDE classpath container to use the new ivy-settings.xml file all was good. Simples!

Posted Under
Uncategorized
Tagged

3 thoughts on “Using Ivy with Springs repository and other Maven repositories

  1. Great start, exactly what I was looking. The spring repo is excellent too.

    I have a trivial problem though. I placed ivysettings.xml into .ivy2 folder (default home folder) and when I run ant, I get this

    No ivy:settings found for the default reference ‘ivy.instance’. A default instance will be used

    I figured out how to exclude sources only. In build.xml, use a type qualifier.

  2. At last! An example that just works.
    I’ve been trying to get this to work for hours.
    Thanks heaps.

Leave a Reply