Apache Ivy : An Agile Dependency Manager

Posted on Posted in Custom Programming, Java, Technology Center

Ivy Dependency Manager

Like most of us often hear, “its another framework or dependency management tool”. But what exactly differentiates Ivy from Maven?

Ivy is much easier to use. The library is simpler since it doesn’t do so much. It only focuses on dependency management and use the already famous and powerful ant to build the application. In short, ant and ivy is used side by side.

Why I Choose Ivy?

The main thing I like about Ivy is its simplicity. You can use Ivy with only ant installed on your system (and of course, java). This means that you don’t need to download any Ivy related libraries or when using eclipse, no plug-in is needed. You can run everything using ant, from installing the ivy library to downloading the dependencies.

Ivy is a dependency management tool that can use other repository such as maven repository.

Installing Ivy

Before continuing, I’ll assume that you are using ant version 1.7. You can choose to run the ant script in either console or from inside eclipse (It depends on your preference).

Here is a build.xml file that contains several targets that will be used in this post:

Invoke “ant install-ivy” and the ivy jars will be downloaded. A new folder named “ivy” will be created with the ivy.jar in it.

Downloading Dependencies

By default ivy uses maven 2 repository but you can certainly define other repository (It will be covered on later post).

The build.xml above contains a target named “resolve”. Running the target will cause the Ivy to download defined dependencies on ivy.xml (ivy.xml is needed since all the dependencies are defined on that file). Here is an example of ivy.xml:

The code above downloads the log4j and its dependencies from the defined repository (in our case, maven repo). I chose to use log4j because in the next section, I’ll be demonstrating to compile a simple java class that uses a Ivy managed library. Invoke “ant resolve” now and you will see a message saying that the library is being downloaded.

Compiling The Application


import org.apache.log4j.Logger;
public class Main {
    private static final Logger log = Logger.getLogger(Main.class);
    public static void main(String[] args) {
        System.out.println("Printed using system.out.println");
        log.info("Printed using log4j logger");

The sample java file won’t really print the message being logged. The purpose of this example is to test compiling the application with the Ivy libraries being referenced. The idea is to simply add the “lib” dir to the classpath on compilation.

Try invoking “ant run” and the application will be compiled and executed. Note that invoking the “ant clean-libs” and removing the “resolve” dependency on run target will cause the compilation to throw some error.




  • Ivy logo is property of Apache Ivy and is not connected with Ideyatech.



3 thoughts on “Apache Ivy : An Agile Dependency Manager

  1. I’m very happy to read this. This is the type of manual that needs to be given and not the accidental misinformation that’s at the other blogs. Appreciate your sharing this best doc.

  2. I have some project’s that integrates ivy, i publish my artifact in two possible repositories, local, that respond to a folder, and beta, that respond to a server where archiva is installed and where i share my jars with my colleague. Now the problem: i need to find a way to build a resolution chains that do this things:
    1)search between the various repository the latest.integration.
    2)retrieve that jar.
    3)if that jar is already in my cache do not have to download it.
    4)if the artifact in the cache has the same version of the artifact in one of the repository take the latest in chronology’s order.

    now i have try everything that’s the setting Ivy setting

    that’s the target of resolve in the Build.xml file:

    and that’s an example on how the dependency are written in ivy.xml file

    the questions are two: First of all is there any error according to my needs? Second, what i’m trying to do, is possible?

    i asked these two questions because it seems to me that setting checkmodified true and changing true let my application skip entirely my cache, and my projects continuing to download the artifacts every time.

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.