Class Resolve.ArtifactConsumer
- All Implemented Interfaces:
Cloneable
- Direct Known Subclasses:
Resolve.Files,Resolve.Path,Resolve.Props
- Enclosing class:
Resolve
Resolve task.
Subclasses of this class define how resolved artifacts are handled, such as copying them to a directory, adding them to a path, or storing their locations in properties. Each consumer may filter artifacts by Maven scope or classpath profile.
ArtifactConsumers are registered by the enclosing Resolve task and invoked after artifacts are
resolved from the dependency graph.
Common subclasses include:
Resolve.Path– Adds artifacts to an Ant<path>referenceResolve.Files– Copies artifacts to a directory and exposes a fileset or resource collectionResolve.Props– Stores artifact file paths as Ant properties
- See Also:
-
Field Summary
Fields inherited from class org.apache.tools.ant.ProjectComponent
description, location, project -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanaccept(org.eclipse.aether.graph.DependencyNode node, List<org.eclipse.aether.graph.DependencyNode> parents) Determines whether the given dependency node should be accepted by this consumer based on its configured dependency filter (e.g., scope or classpath).Returns the classifier this consumer is interested in, if any.abstract voidprocess(org.eclipse.aether.artifact.Artifact artifact, org.eclipse.aether.RepositorySystemSession session) Processes a resolved artifact after dependency resolution has completed.voidsetClasspath(String classpath) Sets a predefined classpath scope configuration using a shorthand string.voidSpecifies the scopes of dependencies to include or exclude during resolution.voidvalidate()Validates the configuration of thisResolve.ArtifactConsumer.Methods inherited from class org.apache.tools.ant.ProjectComponent
clone, getDescription, getLocation, getProject, log, log, setDescription, setLocation, setProject
-
Constructor Details
-
ArtifactConsumer
public ArtifactConsumer()Default constructor for Ant task instantiation.This constructor is used by Ant to create instances of
Resolve.ArtifactConsumersubclasses.
-
-
Method Details
-
accept
public boolean accept(org.eclipse.aether.graph.DependencyNode node, List<org.eclipse.aether.graph.DependencyNode> parents) Determines whether the given dependency node should be accepted by this consumer based on its configured dependency filter (e.g., scope or classpath).- Parameters:
node- the dependency node to evaluateparents- the list of parent nodes leading to this node in the dependency graph- Returns:
trueif the node passes the filter (or no filter is set);falseotherwise
-
getClassifier
Returns the classifier this consumer is interested in, if any.This is typically used to distinguish between main artifacts and attachments like
sourcesorjavadocjars.- Returns:
- the classifier string (e.g.,
"*-sources"), ornullif none
-
validate
public void validate()Validates the configuration of thisResolve.ArtifactConsumer.This default implementation does nothing. Subclasses may override this method to enforce that required attributes (e.g.,
refid) or configurations are present before artifact resolution begins.- Throws:
org.apache.tools.ant.BuildException- if the consumer configuration is invalid
-
process
public abstract void process(org.eclipse.aether.artifact.Artifact artifact, org.eclipse.aether.RepositorySystemSession session) Processes a resolved artifact after dependency resolution has completed.This method is invoked for each artifact that has been accepted by the consumer's filter. Implementations may use this hook to copy files, register references, build paths, or store metadata.
- Parameters:
artifact- the resolvedArtifact, including a file locationsession- theRepositorySystemSessionused during resolution, useful for repository information
-
setScopes
Specifies the scopes of dependencies to include or exclude during resolution.The input string can contain a comma- or space-separated list of scopes. Scopes prefixed with
-or!will be excluded. For example,compile, -testwill include only compile-scope dependencies, excluding those with scopetest.- Parameters:
scopes- a string defining scopes to include/exclude, e.g.,"compile, -test"- Throws:
org.apache.tools.ant.BuildException- if a scope filter was already set (e.g., viasetClasspath(String))
-
setClasspath
Sets a predefined classpath scope configuration using a shorthand string.Accepted values are:
compile— includesprovided,system, andcompilescopesruntime— includescompileandruntimescopestest— includesprovided,system,compile,runtime, andtestscopes
Internally, this method delegates to
setScopes(String)with an appropriate scope string.- Parameters:
classpath- the classpath type to use (compile,runtime, ortest)- Throws:
org.apache.tools.ant.BuildException- if the given classpath is not one of the allowed values
-