[MNG-6759] - Fix issue where MavenMetadataSource failed to set the right repositories when preparing artifact metadata

This commit is contained in:
Stig Rohde Døssing 2019-10-12 00:11:35 +02:00
parent 40f5233313
commit db3e44694c
1 changed files with 6 additions and 0 deletions

View File

@ -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 )
{