Class DefaultArtifact

java.lang.Object
org.eclipse.aether.artifact.AbstractArtifact
org.eclipse.aether.artifact.DefaultArtifact
All Implemented Interfaces:
Artifact

public final class DefaultArtifact extends AbstractArtifact
A simple artifact. Note: Instances of this class are immutable and the exposed mutators return new objects rather than changing the current instance.
  • Constructor Details

    • DefaultArtifact

      public DefaultArtifact(String coords)
      Creates a new artifact with the specified coordinates. If not specified in the artifact coordinates, the artifact's extension defaults to jar and classifier to an empty string.
      Parameters:
      coords - The artifact coordinates in the format <groupId>:<artifactId>[:<extension>[:<classifier>]]:<version>, must not be null.
      Throws:
      IllegalArgumentException - If the artifact coordinates found in coords do not match the expected format.
    • DefaultArtifact

      public DefaultArtifact(String coords, Map<String,String> properties)
      Creates a new artifact with the specified coordinates and properties. If not specified in the artifact coordinates, the artifact's extension defaults to jar and classifier to an empty string.
      Parameters:
      coords - The artifact coordinates in the format <groupId>:<artifactId>[:<extension>[:<classifier>]]:<version>, must not be null.
      properties - The artifact properties, may be null.
      Throws:
      IllegalArgumentException - If the artifact coordinates found in coords do not match the expected format.
    • DefaultArtifact

      public DefaultArtifact(String groupId, String artifactId, String extension, String version)
      Creates a new artifact with the specified coordinates and no classifier. Passing null for any of the coordinates is equivalent to specifying an empty string.
      Parameters:
      groupId - The group identifier of the artifact, may be null.
      artifactId - The artifact identifier of the artifact, may be null.
      extension - The file extension of the artifact, may be null.
      version - The version of the artifact, may be null.
    • DefaultArtifact

      public DefaultArtifact(String groupId, String artifactId, String classifier, String extension, String version)
      Creates a new artifact with the specified coordinates. Passing null for any of the coordinates is equivalent to specifying an empty string.
      Parameters:
      groupId - The group identifier of the artifact, may be null.
      artifactId - The artifact identifier of the artifact, may be null.
      classifier - The classifier of the artifact, may be null.
      extension - The file extension of the artifact, may be null.
      version - The version of the artifact, may be null.
    • DefaultArtifact

      public DefaultArtifact(String groupId, String artifactId, String classifier, String extension, String version, ArtifactType type)
      Creates a new artifact with the specified coordinates. Passing null for any of the coordinates is equivalent to specifying an empty string. The optional artifact type provided to this constructor will be used to determine the artifact's classifier and file extension if the corresponding arguments for this constructor are null.
      Parameters:
      groupId - The group identifier of the artifact, may be null.
      artifactId - The artifact identifier of the artifact, may be null.
      classifier - The classifier of the artifact, may be null.
      extension - The file extension of the artifact, may be null.
      version - The version of the artifact, may be null.
      type - The artifact type from which to query classifier, file extension and properties, may be null.
    • DefaultArtifact

      public DefaultArtifact(String groupId, String artifactId, String classifier, String extension, String version, Map<String,String> properties, ArtifactType type)
      Creates a new artifact with the specified coordinates and properties. Passing null for any of the coordinates is equivalent to specifying an empty string. The optional artifact type provided to this constructor will be used to determine the artifact's classifier and file extension if the corresponding arguments for this constructor are null. If the artifact type specifies properties, those will get merged with the properties passed directly into the constructor, with the latter properties taking precedence.
      Parameters:
      groupId - The group identifier of the artifact, may be null.
      artifactId - The artifact identifier of the artifact, may be null.
      classifier - The classifier of the artifact, may be null.
      extension - The file extension of the artifact, may be null.
      version - The version of the artifact, may be null.
      properties - The properties of the artifact, may be null if none.
      type - The artifact type from which to query classifier, file extension and properties, may be null.
    • DefaultArtifact

      public DefaultArtifact(String groupId, String artifactId, String classifier, String extension, String version, Map<String,String> properties, File file)
      Creates a new artifact with the specified coordinates, properties and file. Passing null for any of the coordinates is equivalent to specifying an empty string.
      Parameters:
      groupId - The group identifier of the artifact, may be null.
      artifactId - The artifact identifier of the artifact, may be null.
      classifier - The classifier of the artifact, may be null.
      extension - The file extension of the artifact, may be null.
      version - The version of the artifact, may be null.
      properties - The properties of the artifact, may be null if none.
      file - The resolved file of the artifact, may be null.
  • Method Details

    • getGroupId

      public String getGroupId()
      Description copied from interface: Artifact
      Gets the group identifier of this artifact, for example "org.apache.maven".
      Returns:
      The group identifier, never null.
    • getArtifactId

      Description copied from interface: Artifact
      Gets the artifact identifier of this artifact, for example "maven-model".
      Returns:
      The artifact identifier, never null.
    • getVersion

      public String getVersion()
      Description copied from interface: Artifact
      Gets the version of this artifact, for example "1.0-20100529-1213". Note that in case of meta versions like "1.0-SNAPSHOT", the artifact's version depends on the state of the artifact. Artifacts that have been resolved or deployed will usually have the meta version expanded.
      Returns:
      The version, never null.
    • getClassifier

      Description copied from interface: Artifact
      Gets the classifier of this artifact, for example "sources".
      Returns:
      The classifier or an empty string if none, never null.
    • getExtension

      public String getExtension()
      Description copied from interface: Artifact
      Gets the (file) extension of this artifact, for example "jar" or "tar.gz".
      Returns:
      The file extension (without leading period), never null.
    • getFile

      public File getFile()
      Description copied from interface: Artifact
      Gets the file of this artifact. Note that only resolved artifacts have a file associated with them. In general, callers must not assume any relationship between an artifact's filename and its coordinates.
      Returns:
      The file or null if the artifact isn't resolved.
    • getProperties

      Description copied from interface: Artifact
      Gets the properties of this artifact. Clients may use these properties to associate non-persistent values with an artifact that help later processing when the artifact gets passed around within the application.
      Returns:
      The (read-only) properties, never null.
      See Also: