Class Resolve.Props

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.Props
All Implemented Interfaces:
Cloneable
Enclosing class:
Resolve

public static class Resolve.Props extends Resolve.ArtifactConsumer
Artifact consumer that maps resolved artifacts to Ant project properties.

Each resolved artifact is converted to a property key-value pair, where the key is based on the artifact coordinates and an optional prefix, and the value is the absolute path to the resolved artifact file.

This is useful for referencing artifacts in other tasks or scripts, especially when integration with tools that expect file paths as properties is needed.

Example output property format: prefix.groupId:artifactId:extension[:classifier] = /path/to/artifact.jar

Example usage:


 <resolve>
   <dependencies>
     <dependency groupId="org.example" artifactId="lib" version="1.0"/>
   </dependencies>
   <properties prefix="mydeps"/>
 </resolve>
 
See Also:
  • Field Summary

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

    description, location, project
  • Constructor Summary

    Constructors
    Constructor
    Description
    This default constructor is used by Ant to create instances of the Resolve.Props consumer.
  • Method Summary

    Modifier and Type
    Method
    Description
    Returns the classifier pattern used to match specific artifact attachments.
    void
    process(org.eclipse.aether.artifact.Artifact artifact, org.eclipse.aether.RepositorySystemSession session)
    Processes a resolved artifact by registering its absolute path as an Ant property.
    void
    setAttachments(String attachments)
    Specifies which type of attachment to resolve.
    void
    setPrefix(String prefix)
    Sets a prefix for the generated Ant property keys.

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

    accept, setClasspath, setScopes, validate

    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

    • Props

      public Props()
      This default constructor is used by Ant to create instances of the Resolve.Props consumer.
  • Method Details

    • setPrefix

      public void setPrefix(String prefix)
      Sets a prefix for the generated Ant property keys. For example, if prefix is resolved, properties will be named like: resolved.groupId:artifactId:type[:classifier].
      Parameters:
      prefix - the property key prefix
    • getClassifier

      public String getClassifier()
      Returns the classifier pattern used to match specific artifact attachments.
      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
    • process

      public void process(org.eclipse.aether.artifact.Artifact artifact, org.eclipse.aether.RepositorySystemSession session)
      Processes a resolved artifact by registering its absolute path as an Ant property. The property name is derived from the artifact coordinates and the optional prefix.
      Specified by:
      process in class Resolve.ArtifactConsumer
      Parameters:
      artifact - the resolved artifact
      session - the current repository session