java.lang.Object
org.apache.tools.ant.ProjectComponent
org.apache.tools.ant.types.DataType
org.apache.maven.resolver.internal.ant.types.Artifacts
All Implemented Interfaces:
Cloneable, ArtifactContainer

public class Artifacts extends org.apache.tools.ant.types.DataType implements ArtifactContainer
A container for one or more Artifact elements in an Ant build script.

This Ant DataType is used to group multiple artifacts, allowing them to be referenced collectively by tasks such as Install or Deploy.

Usage Example:


 <repo:artifacts id="deployment.artifacts">
   <repo:artifact file="target/my-lib.jar" type="jar" groupId="com.example" artifactId="my-lib" version="1.0.0"/>
   <repo:artifact file="target/my-lib.pom" type="pom" groupId="com.example" artifactId="my-lib" version="1.0.0"/>
 </repo:artifacts>

 <repo:deploy artifactsRef="deployment.artifacts"/>
 

Attributes:

  • id — Optional reference ID to reuse the container via artifactsRef.

Nested Elements:

  • <artifact> — A single Maven artifact definition.
  • <artifacts> — Another nested Artifacts element, allowing composition.

This class also supports Ant references via refid, and prevents combining that with nested artifact declarations.

See Also:
  • Field Summary

    Fields inherited from class org.apache.tools.ant.types.DataType

    checked, ref

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

    description, location, project
  • Constructor Summary

    Constructors
    Constructor
    Description
    Default constructor for the Artifacts data type.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Allow Ant to add a single Artifact element to this container.
    void
    Allow Ant to add another Artifacts container as a nested element.
    Collects all Artifact objects from this container and any nested containers.
    protected Artifacts
    Resolves this object if defined as a reference and verifies that it is a Artifacts instance.
    void
    setRefid(org.apache.tools.ant.types.Reference ref)
    Sets a reference to another Artifacts instance.
    void
    validate(org.apache.tools.ant.Task task)
    Validates the nested artifact containers.

    Methods inherited from class org.apache.tools.ant.types.DataType

    checkAttributesAllowed, checkChildrenAllowed, circularReference, clone, dieOnCircularReference, dieOnCircularReference, dieOnCircularReference, getCheckedRef, getCheckedRef, getCheckedRef, getCheckedRef, getCheckedRef, getDataTypeName, getRefid, invokeCircularReferenceCheck, isChecked, isReference, noChildrenAllowed, pushAndInvokeCircularReferenceCheck, setChecked, tooManyAttributes, toString

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

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

    Methods inherited from class java.lang.Object

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

    • Artifacts

      public Artifacts()
      Default constructor for the Artifacts data type.
  • Method Details

    • getRef

      protected Artifacts getRef()
      Resolves this object if defined as a reference and verifies that it is a Artifacts instance.
      Returns:
      the referenced Artifacts instance
      Throws:
      org.apache.tools.ant.BuildException - if the reference is invalid
    • validate

      public void validate(org.apache.tools.ant.Task task)
      Validates the nested artifact containers. If this is a reference, delegates to the referenced object.
      Specified by:
      validate in interface ArtifactContainer
      Parameters:
      task - the Ant task using this data type
      Throws:
      org.apache.tools.ant.BuildException - if validation fails
    • setRefid

      public void setRefid(org.apache.tools.ant.types.Reference ref)
      Sets a reference to another Artifacts instance.
      Overrides:
      setRefid in class org.apache.tools.ant.types.DataType
      Parameters:
      ref - the Ant reference
      Throws:
      org.apache.tools.ant.BuildException - if nested artifacts are already defined
    • addArtifact

      public void addArtifact(Artifact artifact)
      Allow Ant to add a single Artifact element to this container.
      Parameters:
      artifact - the artifact to add
    • addArtifacts

      public void addArtifacts(Artifacts artifacts)
      Allow Ant to add another Artifacts container as a nested element.
      Parameters:
      artifacts - the nested container to add
      Throws:
      org.apache.tools.ant.BuildException - if a circular reference is detected
    • getArtifacts

      public List<Artifact> getArtifacts()
      Collects all Artifact objects from this container and any nested containers.
      Specified by:
      getArtifacts in interface ArtifactContainer
      Returns:
      a list of all artifacts