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 java.util.List;
|
||||||
|
|
||||||
import org.apache.maven.artifact.repository.ArtifactRepository;
|
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.Model;
|
||||||
import org.apache.maven.model.building.AbstractModelBuildingListener;
|
import org.apache.maven.model.building.AbstractModelBuildingListener;
|
||||||
import org.apache.maven.model.building.ModelBuildingEvent;
|
import org.apache.maven.model.building.ModelBuildingEvent;
|
||||||
|
@ -105,16 +103,8 @@ class DefaultModelBuildingListener
|
||||||
{
|
{
|
||||||
try
|
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 =
|
ProjectRealmCache.CacheRecord record =
|
||||||
projectBuildingHelper.createProjectRealm( project, model, repositoryRequest );
|
projectBuildingHelper.createProjectRealm( project, model, projectBuildingRequest );
|
||||||
|
|
||||||
project.setClassRealm( record.realm );
|
project.setClassRealm( record.realm );
|
||||||
project.setExtensionArtifactFilter( record.extensionArtifactFilter );
|
project.setExtensionArtifactFilter( record.extensionArtifactFilter );
|
||||||
|
|
|
@ -33,6 +33,7 @@ import org.apache.maven.ArtifactFilterManager;
|
||||||
import org.apache.maven.artifact.Artifact;
|
import org.apache.maven.artifact.Artifact;
|
||||||
import org.apache.maven.artifact.InvalidRepositoryException;
|
import org.apache.maven.artifact.InvalidRepositoryException;
|
||||||
import org.apache.maven.artifact.repository.ArtifactRepository;
|
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.repository.RepositoryRequest;
|
||||||
import org.apache.maven.artifact.resolver.ArtifactResolutionException;
|
import org.apache.maven.artifact.resolver.ArtifactResolutionException;
|
||||||
import org.apache.maven.artifact.resolver.ArtifactResolutionRequest;
|
import org.apache.maven.artifact.resolver.ArtifactResolutionRequest;
|
||||||
|
@ -135,7 +136,7 @@ public class DefaultProjectBuildingHelper
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized ProjectRealmCache.CacheRecord createProjectRealm( MavenProject project, Model model,
|
public synchronized ProjectRealmCache.CacheRecord createProjectRealm( MavenProject project, Model model,
|
||||||
RepositoryRequest repositoryRequest )
|
ProjectBuildingRequest request )
|
||||||
throws PluginResolutionException, PluginVersionResolutionException
|
throws PluginResolutionException, PluginVersionResolutionException
|
||||||
{
|
{
|
||||||
ClassRealm projectRealm = null;
|
ClassRealm projectRealm = null;
|
||||||
|
@ -182,6 +183,14 @@ public class DefaultProjectBuildingHelper
|
||||||
|
|
||||||
List<Artifact> publicArtifacts = new ArrayList<Artifact>();
|
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 )
|
for ( Plugin plugin : extensionPlugins )
|
||||||
{
|
{
|
||||||
if ( plugin.getVersion() == null )
|
if ( plugin.getVersion() == null )
|
||||||
|
@ -201,7 +210,7 @@ public class DefaultProjectBuildingHelper
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
artifacts = resolveExtensionArtifacts( plugin, repositoryRequest );
|
artifacts = resolveExtensionArtifacts( plugin, repositoryRequest, request );
|
||||||
|
|
||||||
recordArtifacts = pluginArtifactsCache.put( plugin, repositoryRequest, null, artifacts );
|
recordArtifacts = pluginArtifactsCache.put( plugin, repositoryRequest, null, artifacts );
|
||||||
}
|
}
|
||||||
|
@ -381,7 +390,8 @@ public class DefaultProjectBuildingHelper
|
||||||
return record;
|
return record;
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<Artifact> resolveExtensionArtifacts( Plugin extensionPlugin, RepositoryRequest repositoryRequest )
|
private List<Artifact> resolveExtensionArtifacts( Plugin extensionPlugin, RepositoryRequest repositoryRequest,
|
||||||
|
ProjectBuildingRequest request )
|
||||||
throws PluginResolutionException
|
throws PluginResolutionException
|
||||||
{
|
{
|
||||||
Artifact extensionArtifact = repositorySystem.createPluginArtifact( extensionPlugin );
|
Artifact extensionArtifact = repositorySystem.createPluginArtifact( extensionPlugin );
|
||||||
|
@ -396,19 +406,22 @@ public class DefaultProjectBuildingHelper
|
||||||
|
|
||||||
ArtifactFilter resolutionFilter = artifactFilterManager.getCoreArtifactFilter();
|
ArtifactFilter resolutionFilter = artifactFilterManager.getCoreArtifactFilter();
|
||||||
|
|
||||||
ArtifactResolutionRequest request = new ArtifactResolutionRequest( repositoryRequest );
|
ArtifactResolutionRequest artifactRequest = new ArtifactResolutionRequest( repositoryRequest );
|
||||||
request.setArtifact( extensionArtifact );
|
artifactRequest.setArtifact( extensionArtifact );
|
||||||
request.setArtifactDependencies( overrideArtifacts );
|
artifactRequest.setArtifactDependencies( overrideArtifacts );
|
||||||
request.setCollectionFilter( collectionFilter );
|
artifactRequest.setCollectionFilter( collectionFilter );
|
||||||
request.setResolutionFilter( resolutionFilter );
|
artifactRequest.setResolutionFilter( resolutionFilter );
|
||||||
request.setResolveRoot( true );
|
artifactRequest.setResolveRoot( true );
|
||||||
request.setResolveTransitively( 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
|
try
|
||||||
{
|
{
|
||||||
resolutionErrorHandler.throwErrors( request, result );
|
resolutionErrorHandler.throwErrors( artifactRequest, result );
|
||||||
}
|
}
|
||||||
catch ( ArtifactResolutionException e )
|
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 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 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}.
|
* @return The record with the project realm and extension artifact filter, never {@code null}.
|
||||||
* @throws PluginResolutionException If any build extension could not be resolved.
|
* @throws PluginResolutionException If any build extension could not be resolved.
|
||||||
*/
|
*/
|
||||||
ProjectRealmCache.CacheRecord createProjectRealm( MavenProject project, Model model,
|
ProjectRealmCache.CacheRecord createProjectRealm( MavenProject project, Model model, ProjectBuildingRequest request )
|
||||||
RepositoryRequest repositoryRequest )
|
|
||||||
throws PluginResolutionException, PluginVersionResolutionException;
|
throws PluginResolutionException, PluginVersionResolutionException;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,7 +23,6 @@ import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.apache.maven.artifact.repository.ArtifactRepository;
|
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.Model;
|
||||||
import org.apache.maven.model.Repository;
|
import org.apache.maven.model.Repository;
|
||||||
|
|
||||||
|
@ -51,7 +50,7 @@ public class EmptyProjectBuildingHelper
|
||||||
}
|
}
|
||||||
|
|
||||||
public ProjectRealmCache.CacheRecord createProjectRealm( MavenProject proejct, Model model,
|
public ProjectRealmCache.CacheRecord createProjectRealm( MavenProject proejct, Model model,
|
||||||
RepositoryRequest repositoryRequest )
|
ProjectBuildingRequest request )
|
||||||
{
|
{
|
||||||
return new ProjectRealmCache.CacheRecord( null, null );
|
return new ProjectRealmCache.CacheRecord( null, null );
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue