Package org.apache.maven.api
Interface Artifact
- All Known Subinterfaces:
Dependency
,DownloadedArtifact
,DownloadedDependency
,ProducedArtifact
- All Known Implementing Classes:
DefaultArtifact
,DefaultDependency
,DefaultDownloadedArtifact
,DefaultProducedArtifact
A Maven artifact is a file, typically a JAR, that is produced and used by Maven projects.
It is identified by a unique combination of a group ID, artifact ID, version, classifier,
and extension, and it is stored in a repository for dependency management and build purposes.
Each Artifact
instance is basically an exact pointer to a file in a Maven repository.
Artifact
instances are created when resolving ArtifactCoordinates
instances.
Resolving is the process that selects a particular version
and downloads the artifact in the local repository. This operation returns a DownloadedArtifact
.
- Since:
- 4.0.0
-
Method Summary
Modifier and TypeMethodDescriptionReturns the identifier of the artifact.Returns the version or meta-version of the artifact.Returns the classifier of the artifact.Returns the file extension of the artifact.Returns the group identifier of the artifact.Returns the version of the artifact.boolean
Determines whether this artifact uses a snapshot version.default String
key()
Returns a unique identifier for this artifact.Returns coordinates with the same identifiers as this artifact.
-
Method Details
-
key
Returns a unique identifier for this artifact. The identifier is composed of groupId, artifactId, extension, classifier, and version.- Returns:
- a unique identifier for this artifact
- See Also:
-
getGroupId
Returns the group identifier of the artifact.- Returns:
- the group identifier of the artifact
- See Also:
-
getArtifactId
Returns the identifier of the artifact.- Returns:
- the identifier of the artifact
- See Also:
-
getVersion
Returns the version of the artifact. Contrarily toArtifactCoordinates
, eachArtifact
is associated to a specific version instead of a range of versions. If the base version contains a meta-version such asSNAPSHOT
, those keywords are replaced by, for example, the actual timestamp.- Returns:
- the version of the artifact
- See Also:
-
getBaseVersion
Returns the version or meta-version of the artifact. A meta-version is a version suffixed with theSNAPSHOT
keyword. Meta-versions are represented in a base version by their symbols (e.g.,SNAPSHOT
), while they are replaced by, for example, the actual timestamp in the version.- Returns:
- the version or meta-version of the artifact
-
getClassifier
Returns the classifier of the artifact.- Returns:
- the classifier or an empty string if none, never
null
- See Also:
-
getExtension
Returns the file extension of the artifact. The dot separator is not included in the returned string.- Returns:
- the file extension or an empty string if none, never
null
- See Also:
-
isSnapshot
boolean isSnapshot()Determines whether this artifact uses a snapshot version.- Returns:
true
if the artifact is a snapshot,false
otherwise- See Also:
-
toCoordinates
Returns coordinates with the same identifiers as this artifact. This is a shortcut forsession.createArtifactCoordinates(artifact)
.- Returns:
- coordinates with the same identifiers as this artifact
- See Also:
-