Ivy – Dependency Manager

Ivy – Dependency Manager


Ivy, a sub-project of Apache Ant project, is a powerful dependency manager. It works to resolve project dependencies. An external XML file defines project dependencies and lists resources necessary to build a project. Ivy then resolves and downloads resources from an artifact repository: either a private repository or one publicly available on the Internet.

Ivy is a tool for managing (recording, tracking, resolving and reporting) project dependencies. It is characterized by the following:

  • Flexibility and configurability – Ivy is essentially process agnostic and is not tied to any methodology or structure. Instead it provides the necessary flexibility and configurability to be adapted to a broad range of dependency management and build processes.
  • Tight integration with Apache Ant – accessible as a standalone tool, Ivy works particularly well with Apache Ant providing a number of powerful Ant tasks ranging from dependency resolution to dependency reporting and publication.

Ivy has a lot of powerful Features, the most popular and useful feature to be noted is its flexibility, integration with ant, and its strong transitive dependencies management engine.

Use Case

Reasons to use dependency manager:

Without a dependency manager, two solutions are often used to store the dependencies of a project: a project lib dir or direct access to a shared repository.

The major drawback of the project lib dir is that the same dependencies are stored in multiple locations if we have several projects using the same dependencies. Moreover, we often see project where dependencies revisions are not documented, which can cause  maintenance problems.

With the shared repository the problem is often to maintain the list of dependencies of the project. This list is often lost within the build file, which does not help maintenance. Moreover, this solution often requires a download of the whole repository, unless homemade dependencies management solution has been used.

Another major drawback of these solutions is that they do not use transitive dependencies.

Transitive dependencies are the dependencies of our dependencies. Managing transitive dependencies allows us to declare dependencies only on our necessity, and not on the module’s necessity. This not only eases our dependencies declaration, but also improves a lot on the maintainability of our project, especially in multi-project environment. Imagine we develop a component used in several other projects. Then each time our component needs a new dependency, without transitive dependencies, we have to update all the projects using our component! And this could be time consuming!


We require only ivy.jar to implement ivy in our projects. We can download this jar from apache site http://ant.apache.org/ivy/download.cgi .

We should be equipped with the knowledge in ANT build tool, to execute this solution.


  • ivy-xxx.jar

Ivy setup:

  • ivy-2.3.0.jar (Take an example of the latest version of Ivy jar) .
  • Download the jar file and place it into ANT_HOME/lib folder.
  • The Project should be structured as shown below

srcThe necessary code configuration that has to be added in ivy settings are given below:

Additional files:
We have to add two more files with existing project given below. Place those files inside project folder in build.xml file path.

  • Ivy.xml file
  • Ivysettings.xml


  • The project tag in build.xml should have the following attribute. This is the first line of the project and it is referred as xml schema of ivy. It will provide support for ivy tags as follows
  • Add the line given below in build.xml which is mentioned in the ivysettings.xml file. It is crucial to give location of ivy settings configuration file, so that it is used during compiling.
  • Add the lines given below in build.xml file. These are all the lines for retrieving the required jars for the project to build. These section placed in a build.xml file and that “ivy:retrieve” tag will download all the jars mentioned in the ivy.xml files lines to retrieve the required jar files mentioned in ivy.xml file. That will be automatically downloaded and placed in the lib folder with little information such as artifact and revision and extension also.
  • If we need to publish the project as jar or war into repository then use the coding given below. By generating the jar or war we can directly deploy them into the repository using publish command. “ivy: publish” tag is used to publish the generated jar into repository. We have to pass the arguments as resolver name and public revision and status. The overwrite attribute is a flag which is used to overwrite the existing jar in a repository.


  • Ivy.xml is the xml placed in a project location. It is used to mention the collection of Jars going to be used in project which are needed to retrieve from the repository or any public repository.
  • Info tag is used to describe the information need for about the jar such as jar belongs to which organization or organization that’s having copyrights of the jar and module information of the project and version details also.
  • Description tag is used to provide additional information about the jar module.
  • Publication tag contains the artifact tag which are provide information about jar or war which are going to be published and jar or war name and other details.
  • Dependencies tag contains  the dependency tag which describes about the jars which are needed for the project.
  • Dependency tag will give information to fetch the jar from the local or public repository with module name organization name and version details.
  • Below are the sample ivy.xml


  • Ivysettings.xml file is the file which is describes the settings about ivy repository where it is located and how the files are downloaded from the server/repository.
  • It also contains the information about how to publish the jars into the repository.
  • Resolvers are used to resolve the dependency jars that are downloading from which location and the type of the file.
  • There are basically two types of resolvers in Ivy: composite and standard.
  • A composite resolver is a resolver which delegates the work to other resolvers.
  • The other resolvers are standard resolvers.
  • Other than that 2 there are another resolver that is Mirrored Resolver. This resolver can resolve dependencies against several mirrors of the same repository.

Here is the list of built-in resolvers:

table 2

  • Resolver contains “ivy” tag which is describing the format of the ivy file of the particular jar file and with location in the repository.
  • Resolver contains “artifact” tag that are also like ivy tag and it will give the organization, module, type, revision with location in the repository
  • More than one resolver are also allowed to define in the ivysettings.xml

A sample ivysettings.xml is given below:

Steps to run:

  • Once the above mentioned settings and configuration everything done, then go for the build your ant build.xml as normal.
  • The new ivy settings now download all required jars from the repository.
  • Using the jars the normal build process will be done. We can publish the jar or war files to the repository and get back all dependency jars from the repository.

Work process:


  • Configure:

   Ivy needs to be configured to be able to resolve your dependencies. This configuration is usually done with a settings file, which defines a set of dependency resolvers. Each resolver is able to find ivy files and/or artifacts, given simple information such as organization, module, revision, artifact name, and artifact type and artifact extension

  • Resolve:

   The resolve time is the moment when ivy actually resolves the dependencies of one module. It first needs to access the ivy file of the module for which it resolves the dependencies.

  • Retrieve:

  What is called retrieve in ivy is the act of copying artifacts from the cache to another directory structure. This is done using a pattern, which indicates to ivy where the files should be copied.

  • Building a path from the cache:

   In some cases, it is preferable to use artifacts directly from the cache. Ivy is able to use the xml report generated at resolve time to build a path of all artifacts required.

  • Reports:

   Ivy is also able to generate readable reports describing the dependencies resolution.

  • Publish:

   Ivy can be used to publish a particular version of a module in your repository, so that it becomes available for future resolving. This task is usually called either manually or from a continuous integration server.

  • Challenges :

  Sometimes some jars are not available in maven repository.  That jars may have source files only. Not easy to handle different version of jars for different projects.

  • Solution :

   We have to download that into our local repository. In our local repository we have to configure them to make use in our projects.  To resolve dependency of the projects we are using ivy.  It is easy to maintain the projects and versions for every projects using Ivy.


Finally, when we opt for managing multiple or inter related projects. We have to choose the dependency manager. It resolves all kind of dependencies. Hence the Apache Ivy is the good for Java Developers.  Apache Ivy also supports the continuous integration. It uses in Jenkins like continuous integration server also.


4921 Views 4 Views Today