From db3e44694c631554aa9f4079b40b1c6f1e1f2f0d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stig=20Rohde=20D=C3=B8ssing?= Date: Sat, 12 Oct 2019 00:11:35 +0200 Subject: [PATCH] [MNG-6759] - Fix issue where MavenMetadataSource failed to set the right repositories when preparing artifact metadata --- .../apache/maven/project/artifact/MavenMetadataSource.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/maven-core/src/main/java/org/apache/maven/project/artifact/MavenMetadataSource.java b/maven-core/src/main/java/org/apache/maven/project/artifact/MavenMetadataSource.java index 6cf9ec5060..1c40af8b98 100644 --- a/maven-core/src/main/java/org/apache/maven/project/artifact/MavenMetadataSource.java +++ b/maven-core/src/main/java/org/apache/maven/project/artifact/MavenMetadataSource.java @@ -34,6 +34,7 @@ import java.util.Set; import org.apache.maven.RepositoryUtils; import org.apache.maven.artifact.Artifact; +import org.apache.maven.artifact.ArtifactUtils; import org.apache.maven.artifact.factory.ArtifactFactory; import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException; import org.apache.maven.artifact.metadata.ArtifactMetadataSource; @@ -53,6 +54,7 @@ import org.apache.maven.artifact.versioning.ArtifactVersion; import org.apache.maven.artifact.versioning.DefaultArtifactVersion; import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException; import org.apache.maven.artifact.versioning.VersionRange; +import org.apache.maven.execution.MavenSession; import org.apache.maven.model.Dependency; import org.apache.maven.model.DependencyManagement; import org.apache.maven.model.DistributionManagement; @@ -191,6 +193,10 @@ public class MavenMetadataSource dependencies = model.getDependencies(); DependencyManagement dependencyManagement = model.getDependencyManagement(); managedDependencies = dependencyManagement == null ? null : dependencyManagement.getDependencies(); + MavenSession session = legacySupport.getSession(); + MavenProject project = session.getProjectMap().get( + ArtifactUtils.key( artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion() ) ); + pomRepositories = project.getRemoteArtifactRepositories(); } else if ( artifact instanceof ArtifactWithDependencies ) {