Interface Artifact

All Known Implementing Classes:
DefaultArtifact

public interface Artifact
Represents an abstract software artifact uniquely identified by its coordinates, which include the group identifier, artifact identifier, extension, classifier, and version. An artifact may optionally be associated with a local file path.

Artifact instances are immutable. Any modification results in a new object, leaving the original unchanged.

This interface defines methods for retrieving artifact metadata and creating modified copies with updated properties.

Author:
Mikolaj Izdebski
  • Field Details

    • DEFAULT_EXTENSION

      static final String DEFAULT_EXTENSION
      Default extension used when no explicit extension is specified.
      See Also:
    • DEFAULT_VERSION

      static final String DEFAULT_VERSION
      Default version used when no explicit version is specified.
      See Also:
    • MF_KEY_GROUPID

      static final String MF_KEY_GROUPID
      Manifest key for storing the group identifier.
      See Also:
    • MF_KEY_ARTIFACTID

      static final String MF_KEY_ARTIFACTID
      Manifest key for storing the artifact identifier.
      See Also:
    • MF_KEY_EXTENSION

      static final String MF_KEY_EXTENSION
      Manifest key for storing the artifact extension.
      See Also:
    • MF_KEY_CLASSIFIER

      static final String MF_KEY_CLASSIFIER
      Manifest key for storing the artifact classifier.
      See Also:
    • MF_KEY_VERSION

      static final String MF_KEY_VERSION
      Manifest key for storing the artifact version.
      See Also:
  • Method Details

    • getGroupId

      String getGroupId()
      Returns the group identifier of this artifact.
      Returns:
      the group identifier, never null
    • getArtifactId

      String getArtifactId()
      Returns the artifact identifier of this artifact.
      Returns:
      the artifact identifier, never null
    • getExtension

      String getExtension()
      Returns the extension of this artifact.
      Returns:
      the artifact extension, never null
    • getClassifier

      String getClassifier()
      Returns the classifier of this artifact.
      Returns:
      the artifact classifier, never null
    • getVersion

      String getVersion()
      Returns the version of this artifact.
      Returns:
      the artifact version, never null
    • getPath

      Path getPath()
      Returns the local file path of the artifact, or null if the artifact is unresolved (i.e., has no associated file).
      Returns:
      the artifact file path, or null if not resolved
    • withVersion

      Artifact withVersion(String version)
      Creates a new artifact instance with the specified version.
      Parameters:
      version - the new version to set
      Returns:
      a new artifact instance with the updated version
    • setVersion

      @Deprecated default Artifact setVersion(String version)
      Deprecated.
      Use withVersion(String) instead.
    • withPath

      Artifact withPath(Path path)
      Creates a new artifact instance with the specified file path.
      Parameters:
      path - the new file path to set
      Returns:
      a new artifact instance with the updated path
    • setPath

      @Deprecated default Artifact setPath(Path path)
      Deprecated.
      Use withPath(Path) instead.
    • of

      static Artifact of(String coords)
      Factory method to create an artifact instance from a coordinate string.
      Parameters:
      coords - the artifact coordinates
      Returns:
      a new artifact instance
    • of

      static Artifact of(String groupId, String artifactId)
      Factory method to create an artifact with a group ID and artifact ID.
      Parameters:
      groupId - the group identifier
      artifactId - the artifact identifier
      Returns:
      a new artifact instance
    • of

      static Artifact of(String groupId, String artifactId, String version)
      Factory method to create an artifact with a group ID, artifact ID, and version.
      Parameters:
      groupId - the group identifier
      artifactId - the artifact identifier
      version - the artifact version
      Returns:
      a new artifact instance
    • of

      static Artifact of(String groupId, String artifactId, String extension, String version)
      Factory method to create an artifact with a group ID, artifact ID, extension, and version.
      Parameters:
      groupId - the group identifier
      artifactId - the artifact identifier
      extension - the artifact extension
      version - the artifact version
      Returns:
      a new artifact instance
    • of

      static Artifact of(String groupId, String artifactId, String extension, String classifier, String version)
      Factory method to create an artifact with full coordinates.
      Parameters:
      groupId - the group identifier
      artifactId - the artifact identifier
      extension - the artifact extension
      classifier - the artifact classifier
      version - the artifact version
      Returns:
      a new artifact instance
    • of

      static Artifact of(String groupId, String artifactId, String extension, String classifier, String version, Path path)
      Factory method to create an artifact with full coordinates and a local file path.
      Parameters:
      groupId - the group identifier
      artifactId - the artifact identifier
      extension - the artifact extension
      classifier - the artifact classifier
      version - the artifact version
      path - the local file path
      Returns:
      a new artifact instance