Repository Management with Nexus


4.6. Apache Ant and Apache Ivy

Apache Ivy is a dependency manager often used in Apache Ant builds. It supports the Maven repository format and can be configured to download dependencies that can be declared in the ivy.xml file. This configuration can be contained in the ivysettings.xml. A minimal example for resolving dependencies from a Nexus server running on localhost is shown in Minimal Apache Ivy Settings.

Minimal Apache Ivy Settings. 

  <settings defaultResolver="nexus"/>
  <property name="nexus-public"
      <ibiblio name="nexus" m2compatible="true" root="${nexus-public}"/>

These minimal settings allow the ivy:retrieve task to download the declared dependencies.

To deploy build outputs to a Nexus repository with the ivy:publish task, user credentials and the URL of the target repository have to be added to ivysettings.xml and the makepom and publish tasks have to be configured and invoked.

Full example projects can be found in the ant-ivy folder of the Nexus book examples project. A full build of the simple-project, including downloading the declared dependencies and uploading the build output to Nexus can be invoked with

cd ant-ivy/simple-project
ant deploy

Further details about using these example projects can be found in Chapter 25, Evaluating Nexus Step by Step.