java.lang.Object
org.apache.tools.ant.ProjectComponent
org.apache.tools.ant.Task
org.apache.maven.resolver.internal.ant.tasks.AbstractResolvingTask
org.apache.maven.resolver.internal.ant.tasks.Resolve
All Implemented Interfaces:
Cloneable

public class Resolve extends AbstractResolvingTask
Ant task to resolve dependencies using Maven Resolver.

This task reads dependency and repository definitions (either inline or via references) and resolves them according to the specified scopes and remote repositories. Resolved artifacts can be stored in Ant references or used for further processing (e.g., setting up classpaths).

Usage Example:


 <resolve>
   <dependencies>
     <dependency groupId="org.apache.commons" artifactId="commons-lang3" version="3.18.0"/>
   </dependencies>
   <repositories>
     <repository id="central" url="https://repo.maven.apache.org/maven2"/>
   </repositories>
   <path id="my.classpath"/>
 </resolve>
 

Attributes:

  • failOnMissingDescriptor — whether to fail if a POM file cannot be resolved (default: false)
  • offline — whether to operate in offline mode (default: false)

Nested Elements:

  • <dependencies> — defines one or more dependencies to resolve
  • <repositories> — a container for one or more <repository> elements
  • <repository> — specifies a remote Maven repository
  • <path> — optionally defines an Ant path to which resolved artifacts are added

Ant References Created:

  • May register resolved artifacts under a path reference if <path> is used

Typical Use Cases:

  • Resolving Maven artifacts for use in compilation, testing, or runtime
  • Dynamically constructing classpaths using Maven coordinates
See Also:
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static class 
    Abstract base class for consumers of resolved artifacts in the Resolve task.
    class 
    Artifact consumer that copies resolved artifacts to a local directory and optionally registers them as an Ant FileSet or Resources.
    static class 
    Artifact consumer that adds resolved artifacts to an Ant Path.
    static class 
    Artifact consumer that maps resolved artifacts to Ant project properties.
  • Field Summary

    Fields inherited from class org.apache.maven.resolver.internal.ant.tasks.AbstractResolvingTask

    dependencies, localRepository, remoteRepositories

    Fields inherited from class org.apache.tools.ant.Task

    target, taskName, taskType, wrapper

    Fields inherited from class org.apache.tools.ant.ProjectComponent

    description, location, project
  • Constructor Summary

    Constructors
    Constructor
    Description
    Default constructor used by Ant to create a Resolve task instance.
  • Method Summary

    Modifier and Type
    Method
    Description
    Creates a Resolve.Files consumer to collect resolved artifacts into a directory or resource collection.
    Creates a Resolve.Path consumer that collects resolved artifact files into an Ant <path> reference.
    Creates a Resolve.Props consumer that maps resolved artifacts to Ant project properties.
    void
     
    void
    setFailOnMissingAttachments(boolean failOnMissingAttachments)
    Sets whether the build should fail if an expected attachment (e.g., sources or javadoc) cannot be resolved.

    Methods inherited from class org.apache.maven.resolver.internal.ant.tasks.AbstractResolvingTask

    addDependencies, addRemoteRepo, addRemoteRepos, collectDependencies, createLocalRepo, setDependenciesRef, setRemoteReposRef

    Methods inherited from class org.apache.tools.ant.Task

    bindToOwner, getOwningTarget, getRuntimeConfigurableWrapper, getTaskName, getTaskType, getWrapper, handleErrorFlush, handleErrorOutput, handleFlush, handleInput, handleOutput, init, isInvalid, log, log, log, log, maybeConfigure, perform, reconfigure, setOwningTarget, setRuntimeConfigurableWrapper, setTaskName, setTaskType

    Methods inherited from class org.apache.tools.ant.ProjectComponent

    clone, getDescription, getLocation, getProject, setDescription, setLocation, setProject

    Methods inherited from class java.lang.Object

    equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • Resolve

      public Resolve()
      Default constructor used by Ant to create a Resolve task instance.
  • Method Details

    • setFailOnMissingAttachments

      public void setFailOnMissingAttachments(boolean failOnMissingAttachments)
      Sets whether the build should fail if an expected attachment (e.g., sources or javadoc) cannot be resolved.

      This flag only affects artifact consumers that request classified artifacts, such as sources or javadoc JARs via the attachments attribute.

      If false (default), missing attachments are logged at verbose level and ignored. If true, any unresolved attachment will cause the build to fail.

      Parameters:
      failOnMissingAttachments - true to fail the build on missing attachments; false to ignore them
    • createPath

      public Resolve.Path createPath()
      Creates a Resolve.Path consumer that collects resolved artifact files into an Ant <path> reference.

      This is useful for dynamically constructing classpaths from Maven artifacts. The reference ID must be set via Resolve.Path.setRefId(String) so that the resulting path can be used elsewhere in the build.

      Each resolved artifact is added to the path as a FileResource.

      Returns:
      a new Resolve.Path consumer instance
      See Also:
    • createFiles

      public Resolve.Files createFiles()
      Creates a Resolve.Files consumer to collect resolved artifacts into a directory or resource collection.

      This element allows resolved artifacts to be copied to a specified directory with an optional layout, or referenced as a FileSet or Resources depending on the configuration.

      Returns:
      a new Resolve.Files consumer instance
      See Also:
    • createProperties

      public Resolve.Props createProperties()
      Creates a Resolve.Props consumer that maps resolved artifacts to Ant project properties.

      Each resolved artifact will result in a property assignment using a key composed of the artifact's Maven coordinates, optionally prefixed. The value will be the absolute path to the artifact file.

      Example property name format:

      
         prefix.groupId:artifactId:extension[:classifier]
       
      Returns:
      a new Resolve.Props consumer instance
      See Also:
    • execute

      public void execute() throws org.apache.tools.ant.BuildException
      Overrides:
      execute in class org.apache.tools.ant.Task
      Throws:
      org.apache.tools.ant.BuildException