return result;
}
public RepositorySystemSession newRepositorySession( MavenExecutionRequest request )
{
DefaultRepositorySystemSession session = new DefaultRepositorySystemSession();
session.setCache( request.getRepositoryCache() );
session.setIgnoreInvalidArtifactDescriptor( true ).setIgnoreMissingArtifactDescriptor( true );
session.setUserProps( request.getUserProperties() );
session.setSystemProps( request.getSystemProperties() );
Map<Object, Object> configProps = new LinkedHashMap<Object, Object>();
configProps.put( ConfigurationProperties.USER_AGENT, getUserAgent() );
configProps.put( ConfigurationProperties.INTERACTIVE, Boolean.valueOf( request.isInteractiveMode() ) );
configProps.putAll( request.getSystemProperties() );
configProps.putAll( request.getUserProperties() );
session.setConfigProps( configProps );
session.setOffline( request.isOffline() );
session.setChecksumPolicy( request.getGlobalChecksumPolicy() );
session.setUpdatePolicy( request.isUpdateSnapshots() ? RepositoryPolicy.UPDATE_POLICY_ALWAYS : null );
session.setNotFoundCachingEnabled( !request.isUpdateSnapshots() );
session.setTransferErrorCachingEnabled( !request.isUpdateSnapshots() );
session.setArtifactTypeRegistry( RepositoryUtils.newArtifactTypeRegistry( artifactHandlerManager ) );
LocalRepository localRepo = new LocalRepository( request.getLocalRepository().getBasedir() );
session.setLocalRepositoryManager( repoSystem.newLocalRepositoryManager( localRepo ) );
session.setWorkspaceReader( workspaceRepository );
DefaultSettingsDecryptionRequest decrypt = new DefaultSettingsDecryptionRequest();
decrypt.setProxies( request.getProxies() );
decrypt.setServers( request.getServers() );
SettingsDecryptionResult decrypted = settingsDecrypter.decrypt( decrypt );
if ( logger.isDebugEnabled() )
{
for ( SettingsProblem problem : decrypted.getProblems() )
{
logger.debug( problem.getMessage(), problem.getException() );
}
}
DefaultMirrorSelector mirrorSelector = new DefaultMirrorSelector();
for ( Mirror mirror : request.getMirrors() )
{
mirrorSelector.add( mirror.getId(), mirror.getUrl(), mirror.getLayout(), false, mirror.getMirrorOf(),
mirror.getMirrorOfLayouts() );
}
session.setMirrorSelector( mirrorSelector );
DefaultProxySelector proxySelector = new DefaultProxySelector();
for ( Proxy proxy : decrypted.getProxies() )
{
Authentication proxyAuth = new Authentication( proxy.getUsername(), proxy.getPassword() );
proxySelector.add( new org.sonatype.aether.repository.Proxy( proxy.getProtocol(), proxy.getHost(), proxy.getPort(),
proxyAuth ), proxy.getNonProxyHosts() );
}
session.setProxySelector( proxySelector );
DefaultAuthenticationSelector authSelector = new DefaultAuthenticationSelector();
for ( Server server : decrypted.getServers() )
{
Authentication auth =
new Authentication( server.getUsername(), server.getPassword(), server.getPrivateKey(),
server.getPassphrase() );
authSelector.add( server.getId(), auth );
}
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 ChainedDependencyGraphTransformer( new ConflictMarker(), new JavaEffectiveScopeCalculator(),
new NearestVersionConflictResolver(),
new JavaDependencyContextRefiner() );
session.setDependencyGraphTransformer( transformer );
session.setTransferListener( request.getTransferListener() );
session.setRepositoryListener( new AbstractRepositoryListener()
{
@Override
public void artifactInstalling( RepositoryEvent event )
{
logger.info( "Installing " + event.getArtifact().getFile() + " to " + event.getFile() );