mirror of https://github.com/apache/maven.git
[MNG-4991] LegacyRepositorySystem#injectProxy(repositories, proxies) doesn't evaluate non-proxy hosts
git-svn-id: https://svn.apache.org/repos/asf/maven/maven-3/trunk@1073990 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
c38e3d0c49
commit
150984b867
|
@ -24,12 +24,11 @@ import java.util.List;
|
|||
|
||||
import org.apache.maven.artifact.UnknownRepositoryLayoutException;
|
||||
import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
|
||||
import org.apache.maven.execution.MavenExecutionRequest;
|
||||
import org.apache.maven.execution.MavenSession;
|
||||
import org.apache.maven.plugin.LegacySupport;
|
||||
import org.apache.maven.repository.RepositorySystem;
|
||||
import org.codehaus.plexus.component.annotations.Component;
|
||||
import org.codehaus.plexus.component.annotations.Requirement;
|
||||
import org.sonatype.aether.RepositorySystemSession;
|
||||
|
||||
/**
|
||||
* @author jdcasey
|
||||
|
@ -97,24 +96,20 @@ public class DefaultArtifactRepositoryFactory
|
|||
|
||||
private ArtifactRepository injectSession( ArtifactRepository repository, boolean mirrors )
|
||||
{
|
||||
MavenSession session = legacySupport.getSession();
|
||||
RepositorySystemSession session = legacySupport.getRepositorySession();
|
||||
|
||||
if ( session != null && repository != null && !isLocalRepository( repository ) )
|
||||
{
|
||||
MavenExecutionRequest request = session.getRequest();
|
||||
if ( request != null )
|
||||
List<ArtifactRepository> repositories = Arrays.asList( repository );
|
||||
|
||||
if ( mirrors )
|
||||
{
|
||||
List<ArtifactRepository> repositories = Arrays.asList( repository );
|
||||
|
||||
if ( mirrors )
|
||||
{
|
||||
repositorySystem.injectMirror( repositories, request.getMirrors() );
|
||||
}
|
||||
|
||||
repositorySystem.injectProxy( repositories, request.getProxies() );
|
||||
|
||||
repositorySystem.injectAuthentication( repositories, request.getServers() );
|
||||
repositorySystem.injectMirror( session, repositories );
|
||||
}
|
||||
|
||||
repositorySystem.injectProxy( session, repositories );
|
||||
|
||||
repositorySystem.injectAuthentication( session, repositories );
|
||||
}
|
||||
|
||||
return repository;
|
||||
|
|
|
@ -26,13 +26,13 @@ import java.util.List;
|
|||
import org.apache.maven.artifact.InvalidRepositoryException;
|
||||
import org.apache.maven.artifact.repository.ArtifactRepository;
|
||||
import org.apache.maven.artifact.repository.ArtifactRepositoryFactory;
|
||||
import org.apache.maven.execution.MavenExecutionRequest;
|
||||
import org.apache.maven.model.DeploymentRepository;
|
||||
import org.apache.maven.model.Repository;
|
||||
import org.apache.maven.plugin.LegacySupport;
|
||||
import org.apache.maven.repository.RepositorySystem;
|
||||
import org.codehaus.plexus.PlexusContainer;
|
||||
import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
|
||||
import org.sonatype.aether.RepositorySystemSession;
|
||||
|
||||
// This class needs to stick around because it was exposed the the remote resources plugin started using it instead of
|
||||
// getting the repositories from the project.
|
||||
|
@ -75,15 +75,15 @@ public final class ProjectUtils
|
|||
throws InvalidRepositoryException
|
||||
{
|
||||
RepositorySystem repositorySystem = rs( c );
|
||||
MavenExecutionRequest executionRequest = er( c );
|
||||
RepositorySystemSession session = rss( c );
|
||||
|
||||
ArtifactRepository repository = repositorySystem.buildArtifactRepository( repo );
|
||||
|
||||
if ( executionRequest != null )
|
||||
if ( session != null )
|
||||
{
|
||||
repositorySystem.injectMirror( Arrays.asList( repository ), executionRequest.getMirrors() );
|
||||
repositorySystem.injectProxy( Arrays.asList( repository ), executionRequest.getProxies() );
|
||||
repositorySystem.injectAuthentication( Arrays.asList( repository ), executionRequest.getServers() );
|
||||
repositorySystem.injectMirror( session, Arrays.asList( repository ) );
|
||||
repositorySystem.injectProxy( session, Arrays.asList( repository ) );
|
||||
repositorySystem.injectAuthentication( session, Arrays.asList( repository ) );
|
||||
}
|
||||
|
||||
return repository;
|
||||
|
@ -101,20 +101,13 @@ public final class ProjectUtils
|
|||
}
|
||||
}
|
||||
|
||||
private static MavenExecutionRequest er( PlexusContainer c )
|
||||
private static RepositorySystemSession rss( PlexusContainer c )
|
||||
{
|
||||
try
|
||||
{
|
||||
LegacySupport legacySupport = c.lookup( LegacySupport.class );
|
||||
|
||||
if ( legacySupport.getSession() != null )
|
||||
{
|
||||
return legacySupport.getSession().getRequest();
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return legacySupport.getRepositorySession();
|
||||
}
|
||||
catch ( ComponentLookupException e )
|
||||
{
|
||||
|
|
|
@ -65,6 +65,8 @@ import org.apache.maven.settings.crypto.DefaultSettingsDecryptionRequest;
|
|||
import org.apache.maven.settings.crypto.SettingsDecrypter;
|
||||
import org.apache.maven.settings.crypto.SettingsDecryptionRequest;
|
||||
import org.apache.maven.settings.crypto.SettingsDecryptionResult;
|
||||
import org.apache.maven.wagon.proxy.ProxyInfo;
|
||||
import org.apache.maven.wagon.proxy.ProxyUtils;
|
||||
import org.codehaus.plexus.PlexusContainer;
|
||||
import org.codehaus.plexus.component.annotations.Component;
|
||||
import org.codehaus.plexus.component.annotations.Requirement;
|
||||
|
@ -615,7 +617,23 @@ public class LegacyRepositorySystem
|
|||
{
|
||||
if ( proxy.isActive() && repository.getProtocol().equalsIgnoreCase( proxy.getProtocol() ) )
|
||||
{
|
||||
return proxy;
|
||||
if ( StringUtils.isNotEmpty( proxy.getNonProxyHosts() ) )
|
||||
{
|
||||
ProxyInfo pi = new ProxyInfo();
|
||||
pi.setNonProxyHosts( proxy.getNonProxyHosts() );
|
||||
|
||||
org.apache.maven.wagon.repository.Repository repo =
|
||||
new org.apache.maven.wagon.repository.Repository( repository.getId(), repository.getUrl() );
|
||||
|
||||
if ( !ProxyUtils.validateNonProxyHosts( pi, repo.getHost() ) )
|
||||
{
|
||||
return proxy;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return proxy;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue