jump to navigation

Building with Ant and Ivy March 31, 2008

Posted by Phill in General J2EE.
Tags: , , ,
comments closed

At one of my previous workplaces we used to use Maven for our build system, along with Cruise Control.  It was a pretty good system – Maven worked quite well and did all of our dependency management without any problems.

In case you haven’t heard about Maven before, let me quickly explain one of the key benefits of it: you define all the dependencies of a project in an XML file (pom.xml), and during the build process Maven will go and download all the required .jar files for you to use in the build. (Obviously, it caches them so it only downloads the ones you don’t already have!). This is a simplification (Maven can do more), but you get the gist.

If I was starting a “green fields” project, Maven would be a good choice.

Having said that, if you’re already using a project and want the benefits of dependency resolution, or you’re starting a new project and want dependency resolution along with the flexibility of Ant, let me introduce you to an Ant sub-project: Ivy. It’s also a dependency resolution framework, except that it runs from within the Ant build process.  From my experimentations with it, it seems to run out-of-the-box with the Maven repository, and the dependency configuration is very similar.

But there are some very useful things Ivy has which Maven doesn’t, for example you can define a configuration for Oracle and a configuration for SQL Server, and the various .jar files will be included / excluded accordingly.

The Ivy project have a helpful comparison page listing some of the differences between Ivy and Maven 2.

There are a few downsides to dependency resolution, but I will hopefully cover those in a future article!

Advertisements