Class Resolve.Files

java.lang.Object
org.apache.tools.ant.ProjectComponent
org.apache.maven.resolver.internal.ant.tasks.Resolve.ArtifactConsumer
org.apache.maven.resolver.internal.ant.tasks.Resolve.Files
All Implemented Interfaces:
Cloneable
Enclosing class:
Resolve

public class Resolve.Files extends Resolve.ArtifactConsumer
Artifact consumer that copies resolved artifacts to a local directory and optionally registers them as an Ant FileSet or Resources.

This is useful for collecting artifacts into a structured directory or exporting them as a resource collection for further processing in the build.

Usage Examples:


 <resolve>
   <dependencies>
     <dependency groupId="org.example" artifactId="lib" version="1.0"/>
   </dependencies>
   <files refid="resolved.files" dir="libs"/>
 </resolve>
 
See Also:
  • Field Summary

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

    description, location, project
  • Constructor Summary

    Constructors
    Constructor
    Description
    Default constructor for Ant task instantiation.
  • Method Summary

    Modifier and Type
    Method
    Description
    Returns the classifier pattern used to match specific artifact attachments, such as sources or javadoc.
    void
    process(org.eclipse.aether.artifact.Artifact artifact, org.eclipse.aether.RepositorySystemSession session)
    Processes a resolved artifact by copying it to the destination directory or registering it as a resource in the Ant project.
    void
    setAttachments(String attachments)
    Specifies which type of attachment to resolve.
    void
    setDir(File dir)
    Sets the output directory to which resolved artifacts will be copied.
    void
    setLayout(String layout)
    Sets the layout template used to determine the relative path of each artifact when copying files to the target directory.
    void
    Sets the Ant reference ID under which the collected fileset or resources will be registered.
    void
    Validates that either a destination directory or a reference ID is set.

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

    accept, setClasspath, setScopes

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

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

    Methods inherited from class java.lang.Object

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

    • Files

      public Files()
      Default constructor for Ant task instantiation.

      This constructor is used by Ant to create instances of the Resolve.Files consumer.

  • Method Details

    • setRefId

      public void setRefId(String refId)
      Sets the Ant reference ID under which the collected fileset or resources will be registered.
      Parameters:
      refId - the reference ID to assign
    • getClassifier

      public String getClassifier()
      Returns the classifier pattern used to match specific artifact attachments, such as sources or javadoc.
      Overrides:
      getClassifier in class Resolve.ArtifactConsumer
      Returns:
      the classifier pattern, or null if not set
    • setAttachments

      public void setAttachments(String attachments)
      Specifies which type of attachment to resolve. Valid values are:
      • sources
      • javadoc
      Internally, this sets a classifier pattern for filtering resolved artifacts.
      Parameters:
      attachments - the attachment type
      Throws:
      org.apache.tools.ant.BuildException - if an invalid type is provided
    • setDir

      public void setDir(File dir)
      Sets the output directory to which resolved artifacts will be copied. If this is specified without an explicit layout, a default layout will be used.
      Parameters:
      dir - the destination directory
    • setLayout

      public void setLayout(String layout)
      Sets the layout template used to determine the relative path of each artifact when copying files to the target directory.

      The layout is a string pattern using variables such as ${gid}, ${aid}, ${ver}, ${cls}, and ${ext} to define where artifacts should be placed under the specified dir.

      This method is only meaningful if a dir is specified. If used without a directory, it will result in a BuildException during validation.

      Parameters:
      layout - the path layout pattern to apply for copied artifacts
      See Also:
    • validate

      public void validate()
      Validates that either a destination directory or a reference ID is set.
      Overrides:
      validate in class Resolve.ArtifactConsumer
      Throws:
      org.apache.tools.ant.BuildException - if the configuration is invalid
    • process

      public void process(org.eclipse.aether.artifact.Artifact artifact, org.eclipse.aether.RepositorySystemSession session)
      Processes a resolved artifact by copying it to the destination directory or registering it as a resource in the Ant project.
      Specified by:
      process in class Resolve.ArtifactConsumer
      Parameters:
      artifact - the resolved artifact
      session - the current repository session