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 class
Abstract base class for consumers of resolved artifacts in theResolve
task.class
Artifact consumer that copies resolved artifacts to a local directory and optionally registers them as an AntFileSet
orResources
.static class
Artifact consumer that adds resolved artifacts to an AntPath
.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
ConstructorsConstructorDescriptionResolve()
Default constructor used by Ant to create aResolve
task instance. -
Method Summary
Modifier and TypeMethodDescriptionCreates aResolve.Files
consumer to collect resolved artifacts into a directory or resource collection.Creates aResolve.Path
consumer that collects resolved artifact files into an Ant<path>
reference.Creates aResolve.Props
consumer that maps resolved artifacts to Ant project properties.void
execute()
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
-
Constructor Details
-
Resolve
public Resolve()Default constructor used by Ant to create aResolve
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. Iftrue
, any unresolved attachment will cause the build to fail.- Parameters:
failOnMissingAttachments
-true
to fail the build on missing attachments;false
to ignore them
-
createPath
Creates aResolve.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
Creates aResolve.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
orResources
depending on the configuration.- Returns:
- a new
Resolve.Files
consumer instance - See Also:
-
createProperties
Creates aResolve.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 classorg.apache.tools.ant.Task
- Throws:
org.apache.tools.ant.BuildException
-