This is an automated email from the ASF dual-hosted git repository.

cstamas pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/maven.git

commit c06965db88c5e7c5cd41875d51d4bd1e646f723b
Author: Guillaume Nodet <gno...@gmail.com>
AuthorDate: Fri Oct 18 08:40:00 2024 +0200

    [MNG-8326] The ModelBuilder cannot import BOM with classifiers
---
 .../apache/maven/api/services/model/ModelResolver.java  |  3 +++
 .../internal/impl/resolver/DefaultModelResolver.java    | 17 ++++++++++++-----
 .../transformation/impl/ConsumerPomBuilderTest.java     |  1 +
 3 files changed, 16 insertions(+), 5 deletions(-)

diff --git 
a/maven-api-impl/src/main/java/org/apache/maven/api/services/model/ModelResolver.java
 
b/maven-api-impl/src/main/java/org/apache/maven/api/services/model/ModelResolver.java
index b3a0e2332e..aa8ffdbfe8 100644
--- 
a/maven-api-impl/src/main/java/org/apache/maven/api/services/model/ModelResolver.java
+++ 
b/maven-api-impl/src/main/java/org/apache/maven/api/services/model/ModelResolver.java
@@ -59,6 +59,7 @@ public interface ModelResolver extends Service {
                 parent.getGroupId(),
                 parent.getArtifactId(),
                 parent.getVersion(),
+                null,
                 version -> modified.set(parent.withVersion(version)));
     }
 
@@ -85,6 +86,7 @@ public interface ModelResolver extends Service {
                 dependency.getGroupId(),
                 dependency.getArtifactId(),
                 dependency.getVersion(),
+                dependency.getClassifier(),
                 version -> modified.set(dependency.withVersion(version)));
     }
 
@@ -95,6 +97,7 @@ public interface ModelResolver extends Service {
             @Nonnull String groupId,
             @Nonnull String artifactId,
             @Nonnull String version,
+            @Nullable String classifier,
             @Nonnull Consumer<String> resolvedVersion)
             throws ModelResolverException;
 }
diff --git 
a/maven-api-impl/src/main/java/org/apache/maven/internal/impl/resolver/DefaultModelResolver.java
 
b/maven-api-impl/src/main/java/org/apache/maven/internal/impl/resolver/DefaultModelResolver.java
index 1eaf9f2c8f..9ea3d3f63b 100644
--- 
a/maven-api-impl/src/main/java/org/apache/maven/internal/impl/resolver/DefaultModelResolver.java
+++ 
b/maven-api-impl/src/main/java/org/apache/maven/internal/impl/resolver/DefaultModelResolver.java
@@ -71,6 +71,7 @@ public class DefaultModelResolver implements ModelResolver {
                 parent.getArtifactId(),
                 parent.getVersion(),
                 "parent",
+                null,
                 parent.getLocation("version"),
                 version -> modified.set(parent.withVersion(version)));
     }
@@ -89,6 +90,7 @@ public class DefaultModelResolver implements ModelResolver {
                 dependency.getArtifactId(),
                 dependency.getVersion(),
                 "dependency",
+                dependency.getClassifier(),
                 dependency.getLocation("version"),
                 version -> modified.set(dependency.withVersion(version)));
     }
@@ -100,9 +102,11 @@ public class DefaultModelResolver implements ModelResolver 
{
             @Nonnull String groupId,
             @Nonnull String artifactId,
             @Nonnull String version,
+            @Nullable String classifier,
             @Nonnull Consumer<String> resolvedVersion)
             throws ModelResolverException {
-        return resolveModel(session, repositories, groupId, artifactId, 
version, null, null, resolvedVersion);
+        return resolveModel(
+                session, repositories, groupId, artifactId, version, null, 
classifier, null, resolvedVersion);
     }
 
     @SuppressWarnings("checkstyle:ParameterNumber")
@@ -113,11 +117,13 @@ public class DefaultModelResolver implements 
ModelResolver {
             String artifactId,
             String version,
             String type,
+            String classifier,
             InputLocation location,
             Consumer<String> resolvedVersion)
             throws ModelResolverException {
         try {
-            ArtifactCoordinates coords = 
session.createArtifactCoordinates(groupId, artifactId, version, "pom");
+            ArtifactCoordinates coords =
+                    session.createArtifactCoordinates(groupId, artifactId, 
version, classifier, "pom", null);
             if (coords.getVersionConstraint().getVersionRange() != null
                     && 
coords.getVersionConstraint().getVersionRange().getUpperBoundary() == null) {
                 // Message below is checked for in the MNG-2199 core IT.
@@ -143,7 +149,7 @@ public class DefaultModelResolver implements ModelResolver {
                 resolvedVersion.accept(newVersion);
             }
 
-            Path path = getPath(session, repositories, groupId, artifactId, 
newVersion);
+            Path path = getPath(session, repositories, groupId, artifactId, 
newVersion, classifier);
             return new ResolverModelSource(path, groupId + ":" + artifactId + 
":" + newVersion);
         } catch (VersionRangeResolverException | ArtifactResolverException e) {
             throw new ModelResolverException(
@@ -163,9 +169,10 @@ public class DefaultModelResolver implements ModelResolver 
{
             List<RemoteRepository> repositories,
             String groupId,
             String artifactId,
-            String newVersion) {
+            String version,
+            String classifier) {
         DownloadedArtifact resolved = session.resolveArtifact(
-                session.createArtifactCoordinates(groupId, artifactId, 
newVersion, "pom"), repositories);
+                session.createArtifactCoordinates(groupId, artifactId, 
version, classifier, "pom", null), repositories);
         return resolved.getPath();
     }
 
diff --git 
a/maven-core/src/test/java/org/apache/maven/internal/transformation/impl/ConsumerPomBuilderTest.java
 
b/maven-core/src/test/java/org/apache/maven/internal/transformation/impl/ConsumerPomBuilderTest.java
index 2b58df1dc9..6e3d7ae56b 100644
--- 
a/maven-core/src/test/java/org/apache/maven/internal/transformation/impl/ConsumerPomBuilderTest.java
+++ 
b/maven-core/src/test/java/org/apache/maven/internal/transformation/impl/ConsumerPomBuilderTest.java
@@ -136,6 +136,7 @@ public class ConsumerPomBuilderTest extends 
AbstractRepositoryTestCase {
                 String groupId,
                 String artifactId,
                 String version,
+                String classifier,
                 Consumer<String> resolvedVersion)
                 throws ModelResolverException {
             String id = groupId + ":" + artifactId + ":" + version;

Reply via email to