mirror of https://github.com/apache/maven.git
[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
This commit is contained in:
parent
6f3130aa4c
commit
d3534c90bd
|
@ -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 );
|
||||
|
|
|
@ -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<Artifact> publicArtifacts = new ArrayList<Artifact>();
|
||||
|
||||
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<Artifact> resolveExtensionArtifacts( Plugin extensionPlugin, RepositoryRequest repositoryRequest )
|
||||
private List<Artifact> 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 )
|
||||
{
|
||||
|
|
|
@ -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;
|
||||
|
||||
}
|
||||
|
|
|
@ -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 );
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue