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:

AttributeDescriptionRequired Since
filesetIdThe reference ID to store a fileset under, for the resolved dependencies.No
javadocFilesetIdThe reference ID to store a fileset under, for the javadoc attachments of the resolved dependencies.No2.0.9
pathIdThe reference ID to store a path under, for the resolved dependencies.No
pomRefIdThe 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
settingsFileThe settings file to use. Defaults to ${user.home}/.ant/settings.xml or if that doesn't exist ${user.home}/.m2/settings.xml.No2.0.6
sourcesFilesetIdThe reference ID to store a fileset under, for the sources attachments of the resolved dependencies.No2.0.6
typeA comma separated list of artifact types to be retrieved. By default all artifact types will be included.No
pathTypeA comma separated list of artifact types to be added to the path object. By default all artifact types will be included.No
useScopeFollows the Maven scope behaviour. Can be set to compile, runtime, or test. If no value is provided, all scopes will be included.No
scopesA comma separated list of specific scopes to be retrieved. If no value is provided, all scopes will be included.No2.0.10
versionsIdThe property ID to store the versions of the resolved dependencies, for use by a VersionMapper.No2.0.7
cacheDependencyRefsIf 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.No2.1.0
addArtifactFileSetRefsDeprecated 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).No2.0.10
verboseDeprecated 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.

AttributeDescriptionRequired
groupIdThe group ID of the dependency.Yes
artifactIdThe artifact ID of the dependency.Yes
versionThe version of the dependency.Yes
typeThe type of the dependency. The default is jar.No
classifierThe classifier of the dependency.No
scopeThe 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
systemPathFOR 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.

AttributeDescriptionRequired
groupIdThe group ID of the dependency to exclude.Yes
artifactIdThe 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.

AttributeDescriptionRequired Since
fileThe file to install in the repository.Yes, unless an attached artifact is specified
pomRefIdThe reference ID from a POM datatype defined earlier in the build file.Yes, unless a pom nested element is provided instead
settingsFileThe settings file to use. Defaults to ${user.home}/.ant/settings.xml or if that doesn't exist ${user.home}/.m2/settings.xml.No2.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 timeNo, 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, ...

AttributeDescriptionRequired
fileThe file to attach.Yes
typeThe type of the file. Defaults to jar.No
classifierThe classifier of the file.No

install-provider

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

AttributeDescriptionRequired Since
artifactIdThe artifact ID of the provider to install.Yes
groupIdThe group ID of the provider to install. The default is org.apache.maven.wagon.No2.0.7
versionThe version of the provider to install.Yes

writepom (since 2.1.0)

This task will write a POM object to a file.

AttributeDescriptionRequired
pomRefIdThe ID of the POM to write.Yes
fileThe name of the file to write the POMYes
trimA 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.

AttributeDescriptionRequired Since
pomThe pom.xml file to use. If not specified Maven will look for a pom.xml in the current directoryNo2.0.10
mavenHomeThe MAVEN_HOME of the version of Maven to launch. If not specified then mavenVersion will control the version of Maven that is launched.No2.0.10
mavenVersionThe 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.No2.0.10
localRepositoryThe location of the local repository to be used by Maven.No2.0.10
batchModeWhether to launch Maven in batch mode or not. Defaults to true.No2.0.10

Type Reference

localRepository

Specifies the location of the local repository of artifacts.

AttributeDescriptionRequired Since
layoutThe layout of the local repository. The valid options are legacy (Maven 1), or default (Maven 2). Defaults to default.No
pathThe directory of the local repository.Yes2.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.

AttributeDescriptionRequired
idA unique ID of the repository.Yes
urlThe URL of the repository.Yes
layoutThe 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.

AttributeDescriptionRequired
checksumPolicyHow to treat missing or incorrect checksums for the dependencies that are downloaded. Valid values are warn (default) and fail.No
enabledWhether to download this type of artifact from the repository. Default is true.No
updatePolicyHow 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.

AttributeDescriptionRequired Since
fileThe file of the POM to load.Yes
idThe reference ID of this POM.No
refidThe reference ID to use a previously defined POM.No
inheritAllPropertiesIf 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.No2.1.0
settingsFileThe settings file to use. Defaults to ${user.home}/.ant/settings.xml or if that doesn't exist ${user.home}/.m2/settings.xml.No2.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.

AttributeDescriptionRequired
idThe id of the profile to be activated/deactivated.Yes
activeSet 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.

AttributeDescriptionRequired
fromThe versions of the dependencies, as set by versionsId attribute of dependencies task.Yes
toIf 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.