reapplied commit 994a27d004 after Eclipse

Aether merge:
removed code duplication: maven-core should use base
MavenRepositorySystemUtils provided by maven-aether-provider as a
basis before adding environment configuration instead of copy/paste
Aether configuration
This commit is contained in:
Hervé Boutemy 2013-04-09 08:27:06 +02:00
parent 1e5a78792b
commit d7b31b3c90
1 changed files with 2 additions and 38 deletions

View File

@ -62,6 +62,7 @@ import org.apache.maven.project.ProjectBuildingResult;
import org.apache.maven.project.ProjectSorter; import org.apache.maven.project.ProjectSorter;
import org.apache.maven.repository.DelegatingLocalArtifactRepository; import org.apache.maven.repository.DelegatingLocalArtifactRepository;
import org.apache.maven.repository.LocalRepositoryNotAccessibleException; import org.apache.maven.repository.LocalRepositoryNotAccessibleException;
import org.apache.maven.repository.internal.MavenRepositorySystemUtils;
import org.apache.maven.settings.Mirror; import org.apache.maven.settings.Mirror;
import org.apache.maven.settings.Proxy; import org.apache.maven.settings.Proxy;
import org.apache.maven.settings.Server; import org.apache.maven.settings.Server;
@ -83,35 +84,17 @@ import org.eclipse.aether.ConfigurationProperties;
import org.eclipse.aether.DefaultRepositorySystemSession; import org.eclipse.aether.DefaultRepositorySystemSession;
import org.eclipse.aether.RepositorySystem; import org.eclipse.aether.RepositorySystem;
import org.eclipse.aether.RepositorySystemSession; import org.eclipse.aether.RepositorySystemSession;
import org.eclipse.aether.collection.DependencyGraphTransformer;
import org.eclipse.aether.collection.DependencyManager;
import org.eclipse.aether.collection.DependencySelector;
import org.eclipse.aether.collection.DependencyTraverser;
import org.eclipse.aether.repository.LocalRepository; import org.eclipse.aether.repository.LocalRepository;
import org.eclipse.aether.repository.NoLocalRepositoryManagerException; import org.eclipse.aether.repository.NoLocalRepositoryManagerException;
import org.eclipse.aether.repository.RepositoryPolicy; import org.eclipse.aether.repository.RepositoryPolicy;
import org.eclipse.aether.repository.WorkspaceReader; import org.eclipse.aether.repository.WorkspaceReader;
import org.eclipse.aether.resolution.ResolutionErrorPolicy; import org.eclipse.aether.resolution.ResolutionErrorPolicy;
import org.eclipse.aether.spi.localrepo.LocalRepositoryManagerFactory; import org.eclipse.aether.spi.localrepo.LocalRepositoryManagerFactory;
import org.eclipse.aether.util.graph.manager.ClassicDependencyManager;
import org.eclipse.aether.util.graph.selector.AndDependencySelector;
import org.eclipse.aether.util.graph.selector.ExclusionDependencySelector;
import org.eclipse.aether.util.graph.selector.OptionalDependencySelector;
import org.eclipse.aether.util.graph.selector.ScopeDependencySelector;
import org.eclipse.aether.util.graph.transformer.ChainedDependencyGraphTransformer;
import org.eclipse.aether.util.graph.transformer.ConflictResolver;
import org.eclipse.aether.util.graph.transformer.JavaScopeDeriver;
import org.eclipse.aether.util.graph.transformer.JavaScopeSelector;
import org.eclipse.aether.util.graph.transformer.JavaDependencyContextRefiner;
import org.eclipse.aether.util.graph.transformer.NearestVersionSelector;
import org.eclipse.aether.util.graph.transformer.SimpleOptionalitySelector;
import org.eclipse.aether.util.graph.traverser.FatArtifactTraverser;
import org.eclipse.aether.util.repository.AuthenticationBuilder; import org.eclipse.aether.util.repository.AuthenticationBuilder;
import org.eclipse.aether.util.repository.ChainedWorkspaceReader; import org.eclipse.aether.util.repository.ChainedWorkspaceReader;
import org.eclipse.aether.util.repository.DefaultAuthenticationSelector; import org.eclipse.aether.util.repository.DefaultAuthenticationSelector;
import org.eclipse.aether.util.repository.DefaultMirrorSelector; import org.eclipse.aether.util.repository.DefaultMirrorSelector;
import org.eclipse.aether.util.repository.DefaultProxySelector; import org.eclipse.aether.util.repository.DefaultProxySelector;
import org.eclipse.aether.util.repository.SimpleArtifactDescriptorPolicy;
import org.eclipse.aether.util.repository.SimpleResolutionErrorPolicy; import org.eclipse.aether.util.repository.SimpleResolutionErrorPolicy;
/** /**
@ -346,12 +329,10 @@ public class DefaultMaven
public RepositorySystemSession newRepositorySession( MavenExecutionRequest request ) public RepositorySystemSession newRepositorySession( MavenExecutionRequest request )
{ {
DefaultRepositorySystemSession session = new DefaultRepositorySystemSession(); DefaultRepositorySystemSession session = MavenRepositorySystemUtils.newSession();
session.setCache( request.getRepositoryCache() ); session.setCache( request.getRepositoryCache() );
session.setArtifactDescriptorPolicy( new SimpleArtifactDescriptorPolicy( true, true ) );
Map<Object, Object> configProps = new LinkedHashMap<Object, Object>(); Map<Object, Object> configProps = new LinkedHashMap<Object, Object>();
configProps.put( ConfigurationProperties.USER_AGENT, getUserAgent() ); configProps.put( ConfigurationProperties.USER_AGENT, getUserAgent() );
configProps.put( ConfigurationProperties.INTERACTIVE, Boolean.valueOf( request.isInteractiveMode() ) ); configProps.put( ConfigurationProperties.INTERACTIVE, Boolean.valueOf( request.isInteractiveMode() ) );
@ -472,23 +453,6 @@ public class DefaultMaven
} }
session.setAuthenticationSelector( authSelector ); session.setAuthenticationSelector( authSelector );
DependencyTraverser depTraverser = new FatArtifactTraverser();
session.setDependencyTraverser( depTraverser );
DependencyManager depManager = new ClassicDependencyManager();
session.setDependencyManager( depManager );
DependencySelector depFilter =
new AndDependencySelector( new ScopeDependencySelector( "test", "provided" ), new OptionalDependencySelector(),
new ExclusionDependencySelector() );
session.setDependencySelector( depFilter );
DependencyGraphTransformer transformer =
new ConflictResolver( new NearestVersionSelector(), new JavaScopeSelector(),
new SimpleOptionalitySelector(), new JavaScopeDeriver() );
transformer = new ChainedDependencyGraphTransformer( transformer, new JavaDependencyContextRefiner() );
session.setDependencyGraphTransformer( transformer );
session.setTransferListener( request.getTransferListener() ); session.setTransferListener( request.getTransferListener() );
session.setRepositoryListener( eventSpyDispatcher.chainListener( new LoggingRepositoryListener( logger ) ) ); session.setRepositoryListener( eventSpyDispatcher.chainListener( new LoggingRepositoryListener( logger ) ) );