Class Resolve
- All Implemented Interfaces:
Cloneable
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 ClassesModifier and TypeClassDescriptionstatic classAbstract base class for consumers of resolved artifacts in theResolvetask.classArtifact consumer that copies resolved artifacts to a local directory and optionally registers them as an AntFileSetorResources.static classArtifact consumer that adds resolved artifacts to an AntPath.static classArtifact 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, remoteRepositoriesFields inherited from class org.apache.tools.ant.Task
target, taskName, taskType, wrapperFields inherited from class org.apache.tools.ant.ProjectComponent
description, location, project -
Constructor Summary
ConstructorsConstructorDescriptionResolve()Default constructor used by Ant to create aResolvetask instance. -
Method Summary
Modifier and TypeMethodDescriptionCreates aResolve.Filesconsumer to collect resolved artifacts into a directory or resource collection.Creates aResolve.Pathconsumer that collects resolved artifact files into an Ant<path>reference.Creates aResolve.Propsconsumer that maps resolved artifacts to Ant project properties.voidexecute()voidsetFailOnMissingAttachments(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, setRemoteReposRefMethods 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, setTaskTypeMethods inherited from class org.apache.tools.ant.ProjectComponent
clone, getDescription, getLocation, getProject, setDescription, setLocation, setProject
-
Constructor Details
-
Resolve
public Resolve()Default constructor used by Ant to create aResolvetask 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
attachmentsattribute.If
false(default), missing attachments are logged at verbose level and ignored. Iftrue, any unresolved attachment will cause the build to fail.- Parameters:
failOnMissingAttachments-trueto fail the build on missing attachments;falseto ignore them
-
createPath
Creates aResolve.Pathconsumer 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.Pathconsumer instance - See Also:
-
createFiles
Creates aResolve.Filesconsumer 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
FileSetorResourcesdepending on the configuration.- Returns:
- a new
Resolve.Filesconsumer instance - See Also:
-
createProperties
Creates aResolve.Propsconsumer 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.Propsconsumer instance - See Also:
-
execute
public void execute() throws org.apache.tools.ant.BuildException- Overrides:
executein classorg.apache.tools.ant.Task- Throws:
org.apache.tools.ant.BuildException
-