Task Reference

dependencies

This task will check if any of the specified dependencies, and their dependencies are missing or updated, and download them if necessary. The dependencies will be made available as a fileset or path reference.

The dependencies task accepts the following attributes:

Attribute Description Required Since
filesetId The reference ID to store a fileset under, for the resolved dependencies. No
javadocFilesetId The reference ID to store a fileset under, for the javadoc attachments of the resolved dependencies. No 2.0.9
pathId The reference ID to store a path under, for the resolved dependencies. No
pomRefId The reference ID from a POM datatype defined earlier in the build file. Yes, either this or a pom nested element or one or more dependency nested elements
settingsFile The settings file to use. Defaults to ${user.home}/.ant/settings.xml or if that doesn't exist ${user.home}/.m2/settings.xml. No 2.0.6
sourcesFilesetId The reference ID to store a fileset under, for the sources attachments of the resolved dependencies. No 2.0.6
type A comma separated list of artifact types to be retrieved. By default all artifact types will be included. No
pathType A comma separated list of artifact types to be added to the path object. By default all artifact types will be included. No
useScope Follows the Maven scope behaviour. Can be set to compile, runtime, or test. If no value is provided, all scopes will be included. No
scopes A comma separated list of specific scopes to be retrieved. If no value is provided, all scopes will be included. No 2.0.10
versionsId The property ID to store the versions of the resolved dependencies, for use by a VersionMapper. No 2.0.7
cacheDependencyRefs If set to true, will generate an Ant build file that contains properties and fileset references for the dependencies. Then try to load information from this file in subsequent builds. Default is false. No 2.1.0
addArtifactFileSetRefs Deprecated Add a fileset for each resolved dependency. The fileset has an id of groupId:artifactId:type[:classifier]. Default is true (was false in 2.0.10). No 2.0.10
verbose Deprecated in version 2.1.0. Use the Ant command line -v option for verbose output. No

The task can include the dependency nested type, in addition to the other shared types localRepository, pom and remoteRepository, which will be explained later.

You must include either a single pom element or a pomRefId attribute or one or more dependency elements.

If you have set a value for versionsId, you can later use VersionMapper.

(since 2.0.8) For each dependency resolved, the property groupId:artifactId:type[:classifier] is defined pointing to the corresponding file.

dependency

Dependency definition is done in Maven Ant Tasks exactly like it is done in Maven: it is summarized here, but you can look at the reference documentation for more information.

Attribute Description Required
groupId The group ID of the dependency. Yes
artifactId The artifact ID of the dependency. Yes
version The version of the dependency. Yes
type The type of the dependency. The default is jar. No
classifier The classifier of the dependency. No
scope The scope of the usage of the dependency, which affects which of that dependency's own dependencies are also retrieved. This can be compile (default), runtime, test, provided or system. No
systemPath FOR SYSTEM SCOPE ONLY. This specifies the path on the filesystem for this dependency. No

The dependency can also nest multiple exclusion elements.

Note about system scope

Dependencies that use the system scope specify a path on the local system that may be outside of the local maven repository. An Ant fileset only allows a single base directory, so these dependencies will not be included in the generated fileset for resolved dependencies. They will, however, be included in the path object.

exclusion

An exclusion can be used to prevent the resolution of a particular artifact in the tree of the dependency.

Attribute Description Required
groupId The group ID of the dependency to exclude. Yes
artifactId The artifact ID of the dependency to exclude. Yes

install, deploy

These tasks will install/deploy the given file into the local/remote repository. It is stored using the information in the supplied POM. Multiple artifacts can be attached during install/deploy using attach elements.

Attribute Description Required Since
file The file to install in the repository. Yes, unless an attached artifact is specified
pomRefId The reference ID from a POM datatype defined earlier in the build file. Yes, unless a pom nested element is provided instead
settingsFile The settings file to use. Defaults to ${user.home}/.ant/settings.xml or if that doesn't exist ${user.home}/.m2/settings.xml. No 2.0.6
uniqueVersion (deploy only) Whether to assign snapshots a unique version comprised of the timestamp and build number, or to use the same version each time No, the default is true.

The task must take either a nested pom element, or a pomRefId attribute. Both release and -SNAPSHOT versions are supported. The task can have an optional localRepository nested element.

deploy can have an optional remoteRepository nested element. If no remoteRepository nested element is given, the distributionManagement section of the POM is used.

attach (since 2.0.6)

Multiple artifacts can be attached to the main artifact, for example: sources, javadocs, ...

Attribute Description Required
file The file to attach. Yes
type The type of the file. Defaults to jar. No
classifier The classifier of the file. No

install-provider

This task will install a Wagon provider, to add support for more protocols.

Attribute Description Required Since
artifactId The artifact ID of the provider to install. Yes
groupId The group ID of the provider to install. The default is org.apache.maven.wagon. No 2.0.7
version The version of the provider to install. Yes

writepom (since 2.1.0)

This task will write a POM object to a file.

Attribute Description Required
pomRefId The ID of the POM to write. Yes
file The name of the file to write the POM Yes
trim A boolean value to determine whether unnecessary information should be removed from the POM. Defaults to true. No

mvn (since 2.0.10)

This task will run a Maven process either from a specific Maven Home, or by downloading the required version and running from the local repository directly. The task extends th java task with the following additional attributes.

Attribute Description Required Since
pom The pom.xml file to use. If not specified Maven will look for a pom.xml in the current directory No 2.0.10
mavenHome The MAVEN_HOME of the version of Maven to launch. If not specified then mavenVersion will control the version of Maven that is launched. No 2.0.10
mavenVersion The version of Maven to launch. The required dependencies will be resolved and Maven will be launched directly from the local repository. There is no requirement to have Maven installed locally. This is ignored if mavenHome is specified. The default value is 2.0.10. Prior to Maven Ant Tasks 2.1.2 only Maven versions in the range [2.0.10,2.2.1] could be launched. Since Maven Ant Tasks 2.1.2 the range has been extended to [2.0.10,3.0.2] newer versions of Maven will probably also work but are untested at this time. No 2.0.10
localRepository The location of the local repository to be used by Maven. No 2.0.10
batchMode Whether to launch Maven in batch mode or not. Defaults to true. No 2.0.10

Type Reference

localRepository

Specifies the location of the local repository of artifacts.

Attribute Description Required Since
layout The layout of the local repository. The valid options are legacy (Maven 1), or default (Maven 2). Defaults to default. No
path The directory of the local repository. Yes 2.0.7

Note: until 2.0.6, attribute path was named location, but this changed in 2.0.7 to solve a conflict with Ant 1.7.

remoteRepository

Specifies the location of a remote repository.

Attribute Description Required
id A unique ID of the repository. Yes
url The URL of the repository. Yes
layout The layout of the remote repository. The valid options are legacy (Maven 1), or default (Maven 2). Defaults to default. No

A remoteRepository can have the following nested elements: releases, snapshots, authentication and proxy.

releases, snapshots

Policies about downloading different types of artifacts.

Attribute Description Required
checksumPolicy How to treat missing or incorrect checksums for the dependencies that are downloaded. Valid values are warn (default) and fail. No
enabled Whether to download this type of artifact from the repository. Default is true. No
updatePolicy How often to check for updates on dependencies that are snapshots or include a range of versions. Valid values are never, interval:MINUTES, daily (default), always. No

authentication

The authentication element is used for passing a username, password and other credentials to the repository either on upload or download. The content is the same as for server in the settings reference.

proxy

The proxy element is typically used for HTTP repositories. The content is the same as for proxy in the settings reference.

pom

The POM element will load a POM file and make it available as a reference for the other tasks or as properties.

Attribute Description Required Since
file The file of the POM to load. Yes
id The reference ID of this POM. No
refid The reference ID to use a previously defined POM. No
inheritAllProperties If set to true, all Ant properties will be passed to the Maven POM. If set to false, only user (command-line) properties will be passed. Defaults to true. No 2.1.0
settingsFile The settings file to use. Defaults to ${user.home}/.ant/settings.xml or if that doesn't exist ${user.home}/.m2/settings.xml. No 2.0.6

profile (since 2.0.10)

Multiple profile elements can be nested within the pom element. By default the profile will be activated. If active is set to false, then the profile will be explicitly deactivated.

Attribute Description Required
id The id of the profile to be activated/deactivated. Yes
active Set to true or false to determine whether the profile should be active. Default is true. No

versionMapper (since 2.0.7)

This is a filename mapper that removes version info from the filename when copying dependencies. It can also, optionally, remove the directory info from the filename.

The full class name to use in classname attribute of <mapper> element is org.apache.maven.artifact.ant.VersionMapper.

Attribute Description Required
from The versions of the dependencies, as set by versionsId attribute of dependencies task. Yes
to If this is set to flatten the directory info is also removed from the filename. No

You can see a full working example in the examples.