The pom task can be used in one of two ways, either to read an existing pom file (typically pom.xml), or to define an in memory pom object. Either technique can be used to resolve build dependencies, build the project classpath, and/or define project properties.

Reading an existing POM file

An example pom is provided here:






These elements represent:

  • modelVersion - this is the version of the POM layout in use, currently 4.0.0.
  • groupId - the group ID represents your organisation and project name, much like a Java package name. This must be universally unique. This becomes the base directory in the repository as well.
  • artifactId - the artifact ID represents the current build unit. It usually equals the filename of the resulting file, and must be unique within the group.
  • version - the version of the artifact you are building.
  • dependencies - the artifacts that this project is dependent on.

This is all that is required for most projects. However, it is also possible to use other fields available in Maven to describe your project, and reference them from your build script.

Once the pom file is created, it can be read by the pom task.

  <artifact:pom id="mypom" file="pom.xml" />

Defining a POM in Ant

If a POM file is not available, the ant task can also be used to define an in-memory pom.

  <artifact:pom id="mypom" groupId="org.acme" artifactId="project1" version="1.0">
    <dependency groupId="junit" artifactId="junit" version="4.1"/>
    <dependency groupId="org.codehaus.plexus" artifactId="plexus-utils" version="1.5.5"/>
    <license name="apache" url=""/>

Accessing POM information

To access a part of the POM as an Ant property, you must define it as a reference. For example, to access the version from a POM, you can use the following:

  <artifact:pom id="mypom" file="pom.xml" />

  <echo>The version is ${mypom.version}</echo>

You can also access nested parts of the POM. For example, you can read the default value of the directory element within the build element using a . separator.

  <artifact:pom id="mypom" file="pom.xml" />

  <echo>The build directory is ${}</echo>

For more information on the elements available in the POM, see the descriptor reference.

Accessing dependencies in the POM

The pom task can be used in combination with the dependencies task to declare a list of dependencies.

  <artifact:pom id="mypom" file="pom.xml" />

  <artifact:dependencies filesetId="mydeps" pomRefId="mypom" />

In this example, the dependencies task will resolve the list of dependencies in the pom and add them to the fileset.

Using profiles in the POM

POM profiles can be activated or deactivated using the nested profile element. For example to activate a profile called my-profile.

    <artifact:pom id="maven.project" file="pom.xml">
      <profile id="my-profile"/>

This can also be used to deactivate a POM profile that is active by default.

    <artifact:pom id="maven.project" file="pom.xml">
      <profile id="my-default-profile" active="false"/>