From eec44b4ace986c9b14e55eaa668720aa92bcb72f Mon Sep 17 00:00:00 2001 From: Guillaume Nodet Date: Fri, 15 Dec 2023 16:48:33 +0100 Subject: [PATCH] [MNG-7971] Add Artifact#getBaseVersion (#1345) --- .../src/main/java/org/apache/maven/api/Artifact.java | 8 ++++++++ .../org/apache/maven/internal/impl/DefaultArtifact.java | 5 +++++ .../org/apache/maven/internal/impl/DefaultDependency.java | 5 +++++ 3 files changed, 18 insertions(+) diff --git a/api/maven-api-core/src/main/java/org/apache/maven/api/Artifact.java b/api/maven-api-core/src/main/java/org/apache/maven/api/Artifact.java index b2d68f1faf..bdc18b958c 100644 --- a/api/maven-api-core/src/main/java/org/apache/maven/api/Artifact.java +++ b/api/maven-api-core/src/main/java/org/apache/maven/api/Artifact.java @@ -73,6 +73,14 @@ public interface Artifact { @Nonnull Version getVersion(); + /** + * The base version of the artifact. + * + * @return the version + */ + @Nonnull + Version getBaseVersion(); + /** * The classifier of the artifact. * diff --git a/maven-core/src/main/java/org/apache/maven/internal/impl/DefaultArtifact.java b/maven-core/src/main/java/org/apache/maven/internal/impl/DefaultArtifact.java index 514d84c34c..4175634ddc 100644 --- a/maven-core/src/main/java/org/apache/maven/internal/impl/DefaultArtifact.java +++ b/maven-core/src/main/java/org/apache/maven/internal/impl/DefaultArtifact.java @@ -75,6 +75,11 @@ public class DefaultArtifact implements Artifact { return session.parseVersion(artifact.getVersion()); } + @Override + public Version getBaseVersion() { + return session.parseVersion(artifact.getBaseVersion()); + } + @Nonnull @Override public String getExtension() { diff --git a/maven-core/src/main/java/org/apache/maven/internal/impl/DefaultDependency.java b/maven-core/src/main/java/org/apache/maven/internal/impl/DefaultDependency.java index e1e17d5848..654c688a0e 100644 --- a/maven-core/src/main/java/org/apache/maven/internal/impl/DefaultDependency.java +++ b/maven-core/src/main/java/org/apache/maven/internal/impl/DefaultDependency.java @@ -86,6 +86,11 @@ public class DefaultDependency implements Dependency { return session.parseVersion(dependency.getArtifact().getVersion()); } + @Override + public Version getBaseVersion() { + return session.parseVersion(dependency.getArtifact().getBaseVersion()); + } + @Override public String getExtension() { return dependency.getArtifact().getExtension();