mirror of https://github.com/apache/maven.git
o Fixed legacy support
git-svn-id: https://svn.apache.org/repos/asf/maven/maven-3/trunk@830161 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
2362f58ef5
commit
ae7f205ae0
|
@ -20,13 +20,16 @@ package org.apache.maven.project;
|
|||
*/
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
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;
|
||||
|
@ -53,28 +56,31 @@ public final class ProjectUtils
|
|||
remoteRepositories.add( buildArtifactRepository( r, artifactRepositoryFactory, c ) );
|
||||
}
|
||||
|
||||
/*
|
||||
* FIXME: The bad dependency relation between maven-core and maven-compat prevents access to LegacySupport here
|
||||
* which is required to get the mirror&authentication settings from the session/request.
|
||||
*/
|
||||
|
||||
return remoteRepositories;
|
||||
}
|
||||
|
||||
public static ArtifactRepository buildDeploymentArtifactRepository( DeploymentRepository repo, ArtifactRepositoryFactory artifactRepositoryFactory, PlexusContainer c )
|
||||
throws InvalidRepositoryException
|
||||
{
|
||||
/*
|
||||
* FIXME: The bad dependency relation between maven-core and maven-compat prevents access to LegacySupport here
|
||||
* which is required to get the authentication settings from the session/request.
|
||||
*/
|
||||
return rs( c ).buildArtifactRepository( repo );
|
||||
return buildArtifactRepository( repo, artifactRepositoryFactory, c );
|
||||
}
|
||||
|
||||
public static ArtifactRepository buildArtifactRepository( Repository repo, ArtifactRepositoryFactory artifactRepositoryFactory, PlexusContainer c )
|
||||
throws InvalidRepositoryException
|
||||
{
|
||||
return rs( c ).buildArtifactRepository( repo );
|
||||
RepositorySystem repositorySystem = rs( c );
|
||||
MavenExecutionRequest executionRequest = er( c );
|
||||
|
||||
ArtifactRepository repository = repositorySystem.buildArtifactRepository( repo );
|
||||
|
||||
if ( executionRequest != null )
|
||||
{
|
||||
repositorySystem.injectMirror( Arrays.asList( repository ), executionRequest.getMirrors() );
|
||||
repositorySystem.injectProxy( Arrays.asList( repository ), executionRequest.getProxies() );
|
||||
repositorySystem.injectAuthentication( Arrays.asList( repository ), executionRequest.getServers() );
|
||||
}
|
||||
|
||||
return repository;
|
||||
}
|
||||
|
||||
private static RepositorySystem rs( PlexusContainer c )
|
||||
|
@ -89,4 +95,25 @@ public final class ProjectUtils
|
|||
}
|
||||
}
|
||||
|
||||
private static MavenExecutionRequest er( PlexusContainer c )
|
||||
{
|
||||
try
|
||||
{
|
||||
LegacySupport legacySupport = c.lookup( LegacySupport.class );
|
||||
|
||||
if ( legacySupport.getSession() != null )
|
||||
{
|
||||
return legacySupport.getSession().getRequest();
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
catch ( ComponentLookupException e )
|
||||
{
|
||||
throw new IllegalStateException( e );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue