Repository Management with Nexus

4.7. Apache Ant and Eclipse Aether

Eclipse Aether is the dependency management component used in Apache Maven 3+. The project provides Ant tasks that can be configured to download dependencies that can be declared in pom.xml file or in the Ant build fiel directly.

This configuration can be contained in your Ant build.xml or a separate file that is imported. A minimal example for resolving dependencies from a Nexus server running on localhost is shown in Minimal Setup for Aether Ant Tasks.

Minimal Setup for Aether Ant Tasks. 

<project xmlns:aether="antlib:org.eclipse.aether.ant" ....>
  <taskdef uri="antlib:org.eclipse.aether.ant" resource="org/eclipse/aether/ant/antlib.xml">
      <fileset dir="${aether.basedir}" includes="aether-ant-tasks-*.jar" />
  <aether:mirror id="mirror" url="http://localhost:8081/nexus/content/groups/public/" mirrorOf="*"/>

These minimal settings allow the aether:resolve task to download the declared dependencies.

To deploy build outputs to a Nexus repository with the aether:deploy task, user authentication and details about the target repositories have to be added .

Full example projects can be found in the ant-aether 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-aether/simple-project
ant deploy

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