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" />

	<dependencies>
		<dependency org="org.springframework" name="org.springframework.context.support"
			rev="2.5.6.A" />
		<dependency org="org.compass-project" name="compass" rev="2.2.0-M2" />
	</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" />
	<resolvers>
		<chain name="spring.compass.ibiblio">
			<url name="com.springsource.repository.bundles.release">
				<ivy pattern="http://repository.springsource.com/ivy/bundles/release/[organisation]/[module]/[revision]/[artifact]-[revision].[ext]" />
				<artifact pattern="http://repository.springsource.com/ivy/bundles/release/[organisation]/[module]/[revision]/[artifact]-[revision].[ext]" />
			</url>
			<url name="com.springsource.repository.bundles.external">
				<ivy pattern="http://repository.springsource.com/ivy/bundles/external/[organisation]/[module]/[revision]/[artifact]-[revision].[ext]" />
				<artifact pattern="http://repository.springsource.com/ivy/bundles/external/[organisation]/[module]/[revision]/[artifact]-[revision].[ext]" />
			</url>
			<ibiblio name="compass" m2compatible="true" root="http://repo.compass-project.org" />
			<ibiblio name="ibiblio" m2compatible="true" />
		</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!

About Matt

I work as a frontend js developer and backend Java developer for an Investment Bank in London. I also wrote and look after subtunes an open source frontend for Subsonic music server. In my spare time I try to DJ, practice Kung Fu and sharpen my code skills
This entry was posted in Java and tagged , , . Bookmark the permalink.

3 Responses to Using Ivy with Springs repository and other Maven repositories

  1. Aaron Satlow says:

    Matty muscles strikes again – saved me a heap of time.

  2. infinity says:

    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.

  3. MrKimi says:

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

Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Spam protection by WP Captcha-Free