Apache IVY - Install Task


Install task is used to install a module and its dependencies in a resolver. It is used when a public artifact is to be downloaded and used in private repository. By default, a user local repository is his/her private repository and is present in ${ivy.default.ivy.user.dir}/local.

Let's create Tester.java, build.xml and ivy.xml as described in IVY - Resolve Task chapter.

Update the build.xml to use the ivy install task.


<project name="test" default="resolve" xmlns:ivy="antlib:org.apache.ivy.ant">
   <target name="resolve" description="resolve dependencies">
      <ivy:resolve />
   <target name="install" description="install dependencies">
      <ivy:install organisation="commons-lang" module="commons-lang" 
         revision="2.6" transitive="true" overwrite="false" 
         from="public" to="local" />

Following are the important terms.

  • organisation − name of the organization.

  • module − module name of the project.

  • revision − version of the project.

  • from − from repository type.

  • to − to repository type.

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 install

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

E:\ivy > ant install
Buildfile: E:\ivy\build.xml

[ivy:install] :: Apache Ivy 2.5.0 - 20191020104435 :: https://ant.apache.org/ivy
/ ::
[ivy:install] :: loading settings :: url = jar:file:/E:/Apache/apache-ant-1.9.14
[ivy:install] :: installing commons-lang#commons-lang;2.6 ::
[ivy:install] :: resolving dependencies ::
[ivy:install]   found commons-lang#commons-lang;2.6 in public
[ivy:install]   found junit#junit;3.8.1 in public
[ivy:install] :: downloading artifacts to cache ::
[ivy:install] :: installing in local ::
[ivy:install]   published commons-lang to C:\Users\Acer\.ivy2\local\commons-lang
[ivy:install]   published commons-lang to C:\Users\Acer\.ivy2\local\commons-lang
[ivy:install]   published commons-lang to C:\Users\Acer\.ivy2\local\commons-lang
[ivy:install]   published ivy to C:\Users\Acer\.ivy2\local\commons-lang\commons-
[ivy:install]   publish committed: moved C:\Users\Acer\.ivy2\local\commons-lang\
[ivy:install]           to C:\Users\Acer\.ivy2\local\commons-lang\commons-lang\2
[ivy:install]   published junit to C:\Users\Acer\.ivy2\local\junit\junit\3.8.1.p
[ivy:install]   published ivy to C:\Users\Acer\.ivy2\local\junit\junit\3.8.1.par
[ivy:install]   publish committed: moved C:\Users\Acer\.ivy2\local\junit\junit\3
[ivy:install]           to C:\Users\Acer\.ivy2\local\junit\junit\3.8.1
[ivy:install] :: install resolution report ::
[ivy:install] :: resolution report :: resolve 0ms :: artifacts dl 21ms
      |                  |            modules            ||   artifacts   |
      |       conf       | number| search|dwnlded|evicted|| number|dwnlded|
      |      default     |   2   |   0   |   0   |   0   ||   4   |   0   |

Total time: 43 seconds

You can verify the downloaded files in ivy cache's default local repository location ${ivy.default.ivy.user.dir} > .ivy2 > local directory.