Apache IVY - Resolve Task


Resolve task is used to resolve dependencies described in ivy.xml, download and put them in ivy cache.

Let's first create a java file Tester.java in E: > ivy > src > com > tutorialspoint folder which will act as source folder for ant project.


package com.tutorialspoint;

import org.apache.commons.lang.StringUtils;

public class Application {
   public static void main(String[] args) {
      String string = StringUtils.upperCase("Ivy Beginner Guide");

Above class is using apache commons lang library to use its class StringUtils. Ivy should download this library and thus it should be defined under dependencies section in ivy.xml. Following is the ivy.xml created in E: > ivy folder.


<?xml version="1.0" encoding="ISO-8859-1"?>
<ivy-module version="2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      <dependency org="org.apache.commons" name="commons-lang3" rev="3.9"/>

Following are the important terms.

  • ivy-module − Root element to identify ivy version, namespace etc.

  • info − element to identify the project as a unique entity.

    • organisation − name of the organization

    • module − name of the module

    • status − status like release, integration or milestone.

  • dependencies − element to contain project dependencies as dependency tags which has following attributes.

    • org − name of the dependency's organization

    • name − name of the dependency.

    • rev − version of the dependency.


<project name="test" default="resolve" xmlns:ivy="antlib:org.apache.ivy.ant">
   <target name="resolve" description="resolve dependencies">
      <ivy:resolve />

Following are the important terms.

  • project − Root element to identify project name, default task namespace for ivy etc.

  • target − target element to create a new task and its description. This contains an ivy resolve task. When ant builds the project, it runs the ivy resolve task which then resolves the dependencies using ivy.

Building the project

As we've all the files ready. Just go the console. Navigate to E: > ivy folder and run the ant command.

E:\ivy > ant

Ivy will come into action, resolving the dependencies, you will see the following result.

Buildfile: E:\ivy\build.xml

[ivy:resolve] :: Apache Ivy 2.5.0 - 20191020104435 :: https://ant.apache.org/ivy
/ ::
[ivy:resolve] :: loading settings :: url = jar:file:/E:/Apache/apache-ant-1.9.14
[ivy:resolve] :: resolving dependencies :: com.tutorialspoint#test;working@Acer-
[ivy:resolve]   confs: [default]
[ivy:resolve]   found commons-lang#commons-lang;2.6 in public
[ivy:resolve]   found junit#junit;3.8.1 in public
[ivy:resolve] :: resolution report :: resolve 375ms :: artifacts dl 79ms
      |                  |            modules            ||   artifacts   |
      |       conf       | number| search|dwnlded|evicted|| number|dwnlded|
      |      default     |   2   |   2   |   0   |   0   ||   4   |   0   |
[ivy:retrieve] :: retrieving :: com.tutorialspoint#test [sync]
[ivy:retrieve]  confs: [default]
[ivy:retrieve]  0 artifacts copied, 2 already retrieved (0kB/101ms)

Total time: 1 second


Resolve Output

Following are the important terms.

  • conf − configuration, in our case we are using default configuration.

  • modules − indicates the total number of modules, downloaded modules etc.

  • artifacts − indicates the total number of artifacts, downloaded artifacts etc.

You can verify the downloaded files in ivy cache's default location in ${ivy.default.ivy.user.dir} > .ivy2 > cache folder. And ${ivy.default.ivy.user.dir} is by default user home: $HOME.