From d3534c90bd1ea160ef9a809313bd71e2c32439a4 Mon Sep 17 00:00:00 2001 From: Benjamin Bentmann Date: Thu, 10 Dec 2009 23:10:28 +0000 Subject: [PATCH] [MNG-4489] [regression] Mirror/proxy/auth does not apply to repositories discovered in POMs of build extensions git-svn-id: https://svn.apache.org/repos/asf/maven/maven-3/trunk@889460 13f79535-47bb-0310-9956-ffa450edef68 --- .../project/DefaultModelBuildingListener.java | 12 +----- .../project/DefaultProjectBuildingHelper.java | 37 +++++++++++++------ .../maven/project/ProjectBuildingHelper.java | 6 +-- .../project/EmptyProjectBuildingHelper.java | 3 +- 4 files changed, 30 insertions(+), 28 deletions(-) diff --git a/maven-core/src/main/java/org/apache/maven/project/DefaultModelBuildingListener.java b/maven-core/src/main/java/org/apache/maven/project/DefaultModelBuildingListener.java index b248d05202..3967ec1329 100644 --- a/maven-core/src/main/java/org/apache/maven/project/DefaultModelBuildingListener.java +++ b/maven-core/src/main/java/org/apache/maven/project/DefaultModelBuildingListener.java @@ -22,8 +22,6 @@ package org.apache.maven.project; import java.util.List; import org.apache.maven.artifact.repository.ArtifactRepository; -import org.apache.maven.artifact.repository.DefaultRepositoryRequest; -import org.apache.maven.artifact.repository.RepositoryRequest; import org.apache.maven.model.Model; import org.apache.maven.model.building.AbstractModelBuildingListener; import org.apache.maven.model.building.ModelBuildingEvent; @@ -105,16 +103,8 @@ class DefaultModelBuildingListener { try { - RepositoryRequest repositoryRequest = new DefaultRepositoryRequest(); - repositoryRequest.setCache( projectBuildingRequest.getRepositoryCache() ); - repositoryRequest.setLocalRepository( projectBuildingRequest.getLocalRepository() ); - repositoryRequest.setRemoteRepositories( pluginRepositories ); - repositoryRequest.setOffline( projectBuildingRequest.isOffline() ); - repositoryRequest.setForceUpdate( projectBuildingRequest.isForceUpdate() ); - repositoryRequest.setTransferListener( projectBuildingRequest.getTransferListener() ); - ProjectRealmCache.CacheRecord record = - projectBuildingHelper.createProjectRealm( project, model, repositoryRequest ); + projectBuildingHelper.createProjectRealm( project, model, projectBuildingRequest ); project.setClassRealm( record.realm ); project.setExtensionArtifactFilter( record.extensionArtifactFilter ); diff --git a/maven-core/src/main/java/org/apache/maven/project/DefaultProjectBuildingHelper.java b/maven-core/src/main/java/org/apache/maven/project/DefaultProjectBuildingHelper.java index 78f3f4e27c..43901d055f 100644 --- a/maven-core/src/main/java/org/apache/maven/project/DefaultProjectBuildingHelper.java +++ b/maven-core/src/main/java/org/apache/maven/project/DefaultProjectBuildingHelper.java @@ -33,6 +33,7 @@ import org.apache.maven.ArtifactFilterManager; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.InvalidRepositoryException; import org.apache.maven.artifact.repository.ArtifactRepository; +import org.apache.maven.artifact.repository.DefaultRepositoryRequest; import org.apache.maven.artifact.repository.RepositoryRequest; import org.apache.maven.artifact.resolver.ArtifactResolutionException; import org.apache.maven.artifact.resolver.ArtifactResolutionRequest; @@ -135,7 +136,7 @@ public class DefaultProjectBuildingHelper } public synchronized ProjectRealmCache.CacheRecord createProjectRealm( MavenProject project, Model model, - RepositoryRequest repositoryRequest ) + ProjectBuildingRequest request ) throws PluginResolutionException, PluginVersionResolutionException { ClassRealm projectRealm = null; @@ -182,6 +183,14 @@ public class DefaultProjectBuildingHelper List publicArtifacts = new ArrayList(); + RepositoryRequest repositoryRequest = new DefaultRepositoryRequest(); + repositoryRequest.setCache( request.getRepositoryCache() ); + repositoryRequest.setLocalRepository( request.getLocalRepository() ); + repositoryRequest.setRemoteRepositories( project.getPluginArtifactRepositories() ); + repositoryRequest.setOffline( request.isOffline() ); + repositoryRequest.setForceUpdate( request.isForceUpdate() ); + repositoryRequest.setTransferListener( request.getTransferListener() ); + for ( Plugin plugin : extensionPlugins ) { if ( plugin.getVersion() == null ) @@ -201,7 +210,7 @@ public class DefaultProjectBuildingHelper } else { - artifacts = resolveExtensionArtifacts( plugin, repositoryRequest ); + artifacts = resolveExtensionArtifacts( plugin, repositoryRequest, request ); recordArtifacts = pluginArtifactsCache.put( plugin, repositoryRequest, null, artifacts ); } @@ -381,7 +390,8 @@ public class DefaultProjectBuildingHelper return record; } - private List resolveExtensionArtifacts( Plugin extensionPlugin, RepositoryRequest repositoryRequest ) + private List resolveExtensionArtifacts( Plugin extensionPlugin, RepositoryRequest repositoryRequest, + ProjectBuildingRequest request ) throws PluginResolutionException { Artifact extensionArtifact = repositorySystem.createPluginArtifact( extensionPlugin ); @@ -396,19 +406,22 @@ public class DefaultProjectBuildingHelper ArtifactFilter resolutionFilter = artifactFilterManager.getCoreArtifactFilter(); - ArtifactResolutionRequest request = new ArtifactResolutionRequest( repositoryRequest ); - request.setArtifact( extensionArtifact ); - request.setArtifactDependencies( overrideArtifacts ); - request.setCollectionFilter( collectionFilter ); - request.setResolutionFilter( resolutionFilter ); - request.setResolveRoot( true ); - request.setResolveTransitively( true ); + ArtifactResolutionRequest artifactRequest = new ArtifactResolutionRequest( repositoryRequest ); + artifactRequest.setArtifact( extensionArtifact ); + artifactRequest.setArtifactDependencies( overrideArtifacts ); + artifactRequest.setCollectionFilter( collectionFilter ); + artifactRequest.setResolutionFilter( resolutionFilter ); + artifactRequest.setResolveRoot( true ); + artifactRequest.setResolveTransitively( true ); + artifactRequest.setServers( request.getServers() ); + artifactRequest.setMirrors( request.getMirrors() ); + artifactRequest.setProxies( request.getProxies() ); - ArtifactResolutionResult result = repositorySystem.resolve( request ); + ArtifactResolutionResult result = repositorySystem.resolve( artifactRequest ); try { - resolutionErrorHandler.throwErrors( request, result ); + resolutionErrorHandler.throwErrors( artifactRequest, result ); } catch ( ArtifactResolutionException e ) { diff --git a/maven-core/src/main/java/org/apache/maven/project/ProjectBuildingHelper.java b/maven-core/src/main/java/org/apache/maven/project/ProjectBuildingHelper.java index 390af575e6..5c540e9eb6 100644 --- a/maven-core/src/main/java/org/apache/maven/project/ProjectBuildingHelper.java +++ b/maven-core/src/main/java/org/apache/maven/project/ProjectBuildingHelper.java @@ -60,12 +60,12 @@ public interface ProjectBuildingHelper * * @param project The project to create the project realm for, must not be {@code null} * @param model The model to create the project realm for, must not be {@code null} - * @param repositoryRequest The repository request to use for artifact resolution, must not be {@code null}. + * @param request The project building request holding further settings like repository settings, must not be + * {@code null}. * @return The record with the project realm and extension artifact filter, never {@code null}. * @throws PluginResolutionException If any build extension could not be resolved. */ - ProjectRealmCache.CacheRecord createProjectRealm( MavenProject project, Model model, - RepositoryRequest repositoryRequest ) + ProjectRealmCache.CacheRecord createProjectRealm( MavenProject project, Model model, ProjectBuildingRequest request ) throws PluginResolutionException, PluginVersionResolutionException; } diff --git a/maven-core/src/test/java/org/apache/maven/project/EmptyProjectBuildingHelper.java b/maven-core/src/test/java/org/apache/maven/project/EmptyProjectBuildingHelper.java index ccf45dea00..9f7d1163fc 100644 --- a/maven-core/src/test/java/org/apache/maven/project/EmptyProjectBuildingHelper.java +++ b/maven-core/src/test/java/org/apache/maven/project/EmptyProjectBuildingHelper.java @@ -23,7 +23,6 @@ import java.util.ArrayList; import java.util.List; import org.apache.maven.artifact.repository.ArtifactRepository; -import org.apache.maven.artifact.repository.RepositoryRequest; import org.apache.maven.model.Model; import org.apache.maven.model.Repository; @@ -51,7 +50,7 @@ public class EmptyProjectBuildingHelper } public ProjectRealmCache.CacheRecord createProjectRealm( MavenProject proejct, Model model, - RepositoryRequest repositoryRequest ) + ProjectBuildingRequest request ) { return new ProjectRealmCache.CacheRecord( null, null ); }