@Test public void testDuplicates() throws IOException, DependencyCollectionException { Dependency dependency = newDep( "duplicate:transitive:ext:dependency" ); CollectRequest request = new CollectRequest( dependency, Arrays.asList( repository ) ); CollectResult result = collector.collectDependencies( session, request ); assertEquals( 0, result.getExceptions().size() ); DependencyNode root = result.getRoot(); Dependency newDependency = root.getDependency(); assertEquals( dependency, newDependency ); assertEquals( dependency.getArtifact(), newDependency.getArtifact() ); assertEquals( 2, root.getChildren().size() ); Dependency dep = newDep( "gid:aid:ext:ver", "compile" ); assertEquals( dep, dep( root, 0 ) ); dep = newDep( "gid:aid2:ext:ver", "compile" ); assertEquals( dep, dep( root, 1 ) ); assertEquals( dep, dep( root, 0, 0 ) ); assertEquals( dep( root, 1 ), dep( root, 0, 0 ) ); }
public CollectResult collectDependencies( RepositorySystemSession session, CollectRequest request ) throws DependencyCollectionException { session = optimizeSession( session ); RequestTrace trace = RequestTrace.newChild( request.getTrace(), request ); CollectResult result = new CollectResult( request ); DependencySelector depSelector = session.getDependencySelector(); DependencyManager depManager = session.getDependencyManager(); DependencyTraverser depTraverser = session.getDependencyTraverser(); VersionFilter verFilter = session.getVersionFilter(); Dependency root = request.getRoot(); List<RemoteRepository> repositories = request.getRepositories(); List<Dependency> dependencies = request.getDependencies(); List<Dependency> managedDependencies = request.getManagedDependencies(); Map<String, Object> stats = logger.isDebugEnabled() ? new LinkedHashMap<String, Object>() : null; long time1 = System.currentTimeMillis(); DefaultDependencyNode node; if ( root != null ) { List<? extends Version> versions; VersionRangeResult rangeResult; try { VersionRangeRequest rangeRequest = new VersionRangeRequest( root.getArtifact(), request.getRepositories(), request.getRequestContext() ); rangeRequest.setTrace( trace ); rangeResult = versionRangeResolver.resolveVersionRange( session, rangeRequest ); versions = filterVersions( root, rangeResult, verFilter, new DefaultVersionFilterContext( session ) ); } catch ( VersionRangeResolutionException e ) { result.addException( e ); throw new DependencyCollectionException( result, e.getMessage() ); } Version version = versions.get( versions.size() - 1 ); root = root.setArtifact( root.getArtifact().setVersion( version.toString() ) ); ArtifactDescriptorResult descriptorResult; try { ArtifactDescriptorRequest descriptorRequest = new ArtifactDescriptorRequest(); descriptorRequest.setArtifact( root.getArtifact() ); descriptorRequest.setRepositories( request.getRepositories() ); descriptorRequest.setRequestContext( request.getRequestContext() ); descriptorRequest.setTrace( trace ); if ( isLackingDescriptor( root.getArtifact() ) ) { descriptorResult = new ArtifactDescriptorResult( descriptorRequest ); } else { descriptorResult = descriptorReader.readArtifactDescriptor( session, descriptorRequest ); } } catch ( ArtifactDescriptorException e ) { result.addException( e ); throw new DependencyCollectionException( result, e.getMessage() ); } root = root.setArtifact( descriptorResult.getArtifact() ); if ( !session.isIgnoreArtifactDescriptorRepositories() ) { repositories = remoteRepositoryManager.aggregateRepositories( session, repositories, descriptorResult.getRepositories(), true ); } dependencies = mergeDeps( dependencies, descriptorResult.getDependencies() ); managedDependencies = mergeDeps( managedDependencies, descriptorResult.getManagedDependencies() ); node = new DefaultDependencyNode( root ); node.setRequestContext( request.getRequestContext() ); node.setRelocations( descriptorResult.getRelocations() ); node.setVersionConstraint( rangeResult.getVersionConstraint() ); node.setVersion( version ); node.setAliases( descriptorResult.getAliases() ); node.setRepositories( request.getRepositories() ); } else { node = new DefaultDependencyNode( request.getRootArtifact() ); } result.setRoot( node ); boolean traverse = root == null || depTraverser == null || depTraverser.traverseDependency( root ); String errorPath = null; if ( traverse && !dependencies.isEmpty() ) { DataPool pool = new DataPool( session ); NodeStack nodes = new NodeStack(); nodes.push( node ); DefaultDependencyCollectionContext context = new DefaultDependencyCollectionContext( session, request.getRootArtifact(), root, managedDependencies ); DefaultVersionFilterContext versionContext = new DefaultVersionFilterContext( session ); Args args = new Args( session, trace, pool, nodes, context, versionContext, request ); Results results = new Results( result, session ); process( args, results, dependencies, repositories, depSelector != null ? depSelector.deriveChildSelector( context ) : null, depManager != null ? depManager.deriveChildManager( context ) : null, depTraverser != null ? depTraverser.deriveChildTraverser( context ) : null, verFilter != null ? verFilter.deriveChildFilter( context ) : null ); errorPath = results.errorPath; } long time2 = System.currentTimeMillis(); DependencyGraphTransformer transformer = session.getDependencyGraphTransformer(); if ( transformer != null ) { try { DefaultDependencyGraphTransformationContext context = new DefaultDependencyGraphTransformationContext( session ); context.put( TransformationContextKeys.STATS, stats ); result.setRoot( transformer.transformGraph( node, context ) ); } catch ( RepositoryException e ) { result.addException( e ); } } if ( stats != null ) { long time3 = System.currentTimeMillis(); stats.put( "DefaultDependencyCollector.collectTime", time2 - time1 ); stats.put( "DefaultDependencyCollector.transformTime", time3 - time2 ); logger.debug( "Dependency collection stats: " + stats ); } if ( errorPath != null ) { throw new DependencyCollectionException( result, "Failed to collect dependencies at " + errorPath ); } if ( !result.getExceptions().isEmpty() ) { throw new DependencyCollectionException( result ); } return result; }
DefaultDependencyCollector implements DependencyCollector, Service { public CollectResult collectDependencies( RepositorySystemSession session, CollectRequest request ) throws DependencyCollectionException { session = optimizeSession( session ); RequestTrace trace = RequestTrace.newChild( request.getTrace(), request ); CollectResult result = new CollectResult( request ); DependencySelector depSelector = session.getDependencySelector(); DependencyManager depManager = session.getDependencyManager(); DependencyTraverser depTraverser = session.getDependencyTraverser(); VersionFilter verFilter = session.getVersionFilter(); Dependency root = request.getRoot(); List<RemoteRepository> repositories = request.getRepositories(); List<Dependency> dependencies = request.getDependencies(); List<Dependency> managedDependencies = request.getManagedDependencies(); Map<String, Object> stats = logger.isDebugEnabled() ? new LinkedHashMap<String, Object>() : null; long time1 = System.currentTimeMillis(); DefaultDependencyNode node; if ( root != null ) { List<? extends Version> versions; VersionRangeResult rangeResult; try { VersionRangeRequest rangeRequest = new VersionRangeRequest( root.getArtifact(), request.getRepositories(), request.getRequestContext() ); rangeRequest.setTrace( trace ); rangeResult = versionRangeResolver.resolveVersionRange( session, rangeRequest ); versions = filterVersions( root, rangeResult, verFilter, new DefaultVersionFilterContext( session ) ); } catch ( VersionRangeResolutionException e ) { result.addException( e ); throw new DependencyCollectionException( result, e.getMessage() ); } Version version = versions.get( versions.size() - 1 ); root = root.setArtifact( root.getArtifact().setVersion( version.toString() ) ); ArtifactDescriptorResult descriptorResult; try { ArtifactDescriptorRequest descriptorRequest = new ArtifactDescriptorRequest(); descriptorRequest.setArtifact( root.getArtifact() ); descriptorRequest.setRepositories( request.getRepositories() ); descriptorRequest.setRequestContext( request.getRequestContext() ); descriptorRequest.setTrace( trace ); if ( isLackingDescriptor( root.getArtifact() ) ) { descriptorResult = new ArtifactDescriptorResult( descriptorRequest ); } else { descriptorResult = descriptorReader.readArtifactDescriptor( session, descriptorRequest ); } } catch ( ArtifactDescriptorException e ) { result.addException( e ); throw new DependencyCollectionException( result, e.getMessage() ); } root = root.setArtifact( descriptorResult.getArtifact() ); if ( !session.isIgnoreArtifactDescriptorRepositories() ) { repositories = remoteRepositoryManager.aggregateRepositories( session, repositories, descriptorResult.getRepositories(), true ); } dependencies = mergeDeps( dependencies, descriptorResult.getDependencies() ); managedDependencies = mergeDeps( managedDependencies, descriptorResult.getManagedDependencies() ); node = new DefaultDependencyNode( root ); node.setRequestContext( request.getRequestContext() ); node.setRelocations( descriptorResult.getRelocations() ); node.setVersionConstraint( rangeResult.getVersionConstraint() ); node.setVersion( version ); node.setAliases( descriptorResult.getAliases() ); node.setRepositories( request.getRepositories() ); } else { node = new DefaultDependencyNode( request.getRootArtifact() ); } result.setRoot( node ); boolean traverse = root == null || depTraverser == null || depTraverser.traverseDependency( root ); String errorPath = null; if ( traverse && !dependencies.isEmpty() ) { DataPool pool = new DataPool( session ); NodeStack nodes = new NodeStack(); nodes.push( node ); DefaultDependencyCollectionContext context = new DefaultDependencyCollectionContext( session, request.getRootArtifact(), root, managedDependencies ); DefaultVersionFilterContext versionContext = new DefaultVersionFilterContext( session ); Args args = new Args( session, trace, pool, nodes, context, versionContext, request ); Results results = new Results( result, session ); process( args, results, dependencies, repositories, depSelector != null ? depSelector.deriveChildSelector( context ) : null, depManager != null ? depManager.deriveChildManager( context ) : null, depTraverser != null ? depTraverser.deriveChildTraverser( context ) : null, verFilter != null ? verFilter.deriveChildFilter( context ) : null ); errorPath = results.errorPath; } long time2 = System.currentTimeMillis(); DependencyGraphTransformer transformer = session.getDependencyGraphTransformer(); if ( transformer != null ) { try { DefaultDependencyGraphTransformationContext context = new DefaultDependencyGraphTransformationContext( session ); context.put( TransformationContextKeys.STATS, stats ); result.setRoot( transformer.transformGraph( node, context ) ); } catch ( RepositoryException e ) { result.addException( e ); } } if ( stats != null ) { long time3 = System.currentTimeMillis(); stats.put( "DefaultDependencyCollector.collectTime", time2 - time1 ); stats.put( "DefaultDependencyCollector.transformTime", time3 - time2 ); logger.debug( "Dependency collection stats: " + stats ); } if ( errorPath != null ) { throw new DependencyCollectionException( result, "Failed to collect dependencies at " + errorPath ); } if ( !result.getExceptions().isEmpty() ) { throw new DependencyCollectionException( result ); } return result; } }
DefaultDependencyCollector implements DependencyCollector, Service { public CollectResult collectDependencies( RepositorySystemSession session, CollectRequest request ) throws DependencyCollectionException { session = optimizeSession( session ); RequestTrace trace = RequestTrace.newChild( request.getTrace(), request ); CollectResult result = new CollectResult( request ); DependencySelector depSelector = session.getDependencySelector(); DependencyManager depManager = session.getDependencyManager(); DependencyTraverser depTraverser = session.getDependencyTraverser(); VersionFilter verFilter = session.getVersionFilter(); Dependency root = request.getRoot(); List<RemoteRepository> repositories = request.getRepositories(); List<Dependency> dependencies = request.getDependencies(); List<Dependency> managedDependencies = request.getManagedDependencies(); Map<String, Object> stats = logger.isDebugEnabled() ? new LinkedHashMap<String, Object>() : null; long time1 = System.currentTimeMillis(); DefaultDependencyNode node; if ( root != null ) { List<? extends Version> versions; VersionRangeResult rangeResult; try { VersionRangeRequest rangeRequest = new VersionRangeRequest( root.getArtifact(), request.getRepositories(), request.getRequestContext() ); rangeRequest.setTrace( trace ); rangeResult = versionRangeResolver.resolveVersionRange( session, rangeRequest ); versions = filterVersions( root, rangeResult, verFilter, new DefaultVersionFilterContext( session ) ); } catch ( VersionRangeResolutionException e ) { result.addException( e ); throw new DependencyCollectionException( result, e.getMessage() ); } Version version = versions.get( versions.size() - 1 ); root = root.setArtifact( root.getArtifact().setVersion( version.toString() ) ); ArtifactDescriptorResult descriptorResult; try { ArtifactDescriptorRequest descriptorRequest = new ArtifactDescriptorRequest(); descriptorRequest.setArtifact( root.getArtifact() ); descriptorRequest.setRepositories( request.getRepositories() ); descriptorRequest.setRequestContext( request.getRequestContext() ); descriptorRequest.setTrace( trace ); if ( isLackingDescriptor( root.getArtifact() ) ) { descriptorResult = new ArtifactDescriptorResult( descriptorRequest ); } else { descriptorResult = descriptorReader.readArtifactDescriptor( session, descriptorRequest ); } } catch ( ArtifactDescriptorException e ) { result.addException( e ); throw new DependencyCollectionException( result, e.getMessage() ); } root = root.setArtifact( descriptorResult.getArtifact() ); if ( !session.isIgnoreArtifactDescriptorRepositories() ) { repositories = remoteRepositoryManager.aggregateRepositories( session, repositories, descriptorResult.getRepositories(), true ); } dependencies = mergeDeps( dependencies, descriptorResult.getDependencies() ); managedDependencies = mergeDeps( managedDependencies, descriptorResult.getManagedDependencies() ); node = new DefaultDependencyNode( root ); node.setRequestContext( request.getRequestContext() ); node.setRelocations( descriptorResult.getRelocations() ); node.setVersionConstraint( rangeResult.getVersionConstraint() ); node.setVersion( version ); node.setAliases( descriptorResult.getAliases() ); node.setRepositories( request.getRepositories() ); } else { node = new DefaultDependencyNode( request.getRootArtifact() ); } result.setRoot( node ); boolean traverse = root == null || depTraverser == null || depTraverser.traverseDependency( root ); String errorPath = null; if ( traverse && !dependencies.isEmpty() ) { DataPool pool = new DataPool( session ); NodeStack nodes = new NodeStack(); nodes.push( node ); DefaultDependencyCollectionContext context = new DefaultDependencyCollectionContext( session, request.getRootArtifact(), root, managedDependencies ); DefaultVersionFilterContext versionContext = new DefaultVersionFilterContext( session ); Args args = new Args( session, trace, pool, nodes, context, versionContext, request ); Results results = new Results( result, session ); process( args, results, dependencies, repositories, depSelector != null ? depSelector.deriveChildSelector( context ) : null, depManager != null ? depManager.deriveChildManager( context ) : null, depTraverser != null ? depTraverser.deriveChildTraverser( context ) : null, verFilter != null ? verFilter.deriveChildFilter( context ) : null ); errorPath = results.errorPath; } long time2 = System.currentTimeMillis(); DependencyGraphTransformer transformer = session.getDependencyGraphTransformer(); if ( transformer != null ) { try { DefaultDependencyGraphTransformationContext context = new DefaultDependencyGraphTransformationContext( session ); context.put( TransformationContextKeys.STATS, stats ); result.setRoot( transformer.transformGraph( node, context ) ); } catch ( RepositoryException e ) { result.addException( e ); } } if ( stats != null ) { long time3 = System.currentTimeMillis(); stats.put( "DefaultDependencyCollector.collectTime", time2 - time1 ); stats.put( "DefaultDependencyCollector.transformTime", time3 - time2 ); logger.debug( "Dependency collection stats: " + stats ); } if ( errorPath != null ) { throw new DependencyCollectionException( result, "Failed to collect dependencies at " + errorPath ); } if ( !result.getExceptions().isEmpty() ) { throw new DependencyCollectionException( result ); } return result; } DefaultDependencyCollector(); @Inject  DefaultDependencyCollector( RemoteRepositoryManager remoteRepositoryManager,
                                ArtifactDescriptorReader artifactDescriptorReader,
                                VersionRangeResolver versionRangeResolver, LoggerFactory loggerFactory ); }
DefaultDependencyCollector implements DependencyCollector, Service { public CollectResult collectDependencies( RepositorySystemSession session, CollectRequest request ) throws DependencyCollectionException { session = optimizeSession( session ); RequestTrace trace = RequestTrace.newChild( request.getTrace(), request ); CollectResult result = new CollectResult( request ); DependencySelector depSelector = session.getDependencySelector(); DependencyManager depManager = session.getDependencyManager(); DependencyTraverser depTraverser = session.getDependencyTraverser(); VersionFilter verFilter = session.getVersionFilter(); Dependency root = request.getRoot(); List<RemoteRepository> repositories = request.getRepositories(); List<Dependency> dependencies = request.getDependencies(); List<Dependency> managedDependencies = request.getManagedDependencies(); Map<String, Object> stats = logger.isDebugEnabled() ? new LinkedHashMap<String, Object>() : null; long time1 = System.currentTimeMillis(); DefaultDependencyNode node; if ( root != null ) { List<? extends Version> versions; VersionRangeResult rangeResult; try { VersionRangeRequest rangeRequest = new VersionRangeRequest( root.getArtifact(), request.getRepositories(), request.getRequestContext() ); rangeRequest.setTrace( trace ); rangeResult = versionRangeResolver.resolveVersionRange( session, rangeRequest ); versions = filterVersions( root, rangeResult, verFilter, new DefaultVersionFilterContext( session ) ); } catch ( VersionRangeResolutionException e ) { result.addException( e ); throw new DependencyCollectionException( result, e.getMessage() ); } Version version = versions.get( versions.size() - 1 ); root = root.setArtifact( root.getArtifact().setVersion( version.toString() ) ); ArtifactDescriptorResult descriptorResult; try { ArtifactDescriptorRequest descriptorRequest = new ArtifactDescriptorRequest(); descriptorRequest.setArtifact( root.getArtifact() ); descriptorRequest.setRepositories( request.getRepositories() ); descriptorRequest.setRequestContext( request.getRequestContext() ); descriptorRequest.setTrace( trace ); if ( isLackingDescriptor( root.getArtifact() ) ) { descriptorResult = new ArtifactDescriptorResult( descriptorRequest ); } else { descriptorResult = descriptorReader.readArtifactDescriptor( session, descriptorRequest ); } } catch ( ArtifactDescriptorException e ) { result.addException( e ); throw new DependencyCollectionException( result, e.getMessage() ); } root = root.setArtifact( descriptorResult.getArtifact() ); if ( !session.isIgnoreArtifactDescriptorRepositories() ) { repositories = remoteRepositoryManager.aggregateRepositories( session, repositories, descriptorResult.getRepositories(), true ); } dependencies = mergeDeps( dependencies, descriptorResult.getDependencies() ); managedDependencies = mergeDeps( managedDependencies, descriptorResult.getManagedDependencies() ); node = new DefaultDependencyNode( root ); node.setRequestContext( request.getRequestContext() ); node.setRelocations( descriptorResult.getRelocations() ); node.setVersionConstraint( rangeResult.getVersionConstraint() ); node.setVersion( version ); node.setAliases( descriptorResult.getAliases() ); node.setRepositories( request.getRepositories() ); } else { node = new DefaultDependencyNode( request.getRootArtifact() ); } result.setRoot( node ); boolean traverse = root == null || depTraverser == null || depTraverser.traverseDependency( root ); String errorPath = null; if ( traverse && !dependencies.isEmpty() ) { DataPool pool = new DataPool( session ); NodeStack nodes = new NodeStack(); nodes.push( node ); DefaultDependencyCollectionContext context = new DefaultDependencyCollectionContext( session, request.getRootArtifact(), root, managedDependencies ); DefaultVersionFilterContext versionContext = new DefaultVersionFilterContext( session ); Args args = new Args( session, trace, pool, nodes, context, versionContext, request ); Results results = new Results( result, session ); process( args, results, dependencies, repositories, depSelector != null ? depSelector.deriveChildSelector( context ) : null, depManager != null ? depManager.deriveChildManager( context ) : null, depTraverser != null ? depTraverser.deriveChildTraverser( context ) : null, verFilter != null ? verFilter.deriveChildFilter( context ) : null ); errorPath = results.errorPath; } long time2 = System.currentTimeMillis(); DependencyGraphTransformer transformer = session.getDependencyGraphTransformer(); if ( transformer != null ) { try { DefaultDependencyGraphTransformationContext context = new DefaultDependencyGraphTransformationContext( session ); context.put( TransformationContextKeys.STATS, stats ); result.setRoot( transformer.transformGraph( node, context ) ); } catch ( RepositoryException e ) { result.addException( e ); } } if ( stats != null ) { long time3 = System.currentTimeMillis(); stats.put( "DefaultDependencyCollector.collectTime", time2 - time1 ); stats.put( "DefaultDependencyCollector.transformTime", time3 - time2 ); logger.debug( "Dependency collection stats: " + stats ); } if ( errorPath != null ) { throw new DependencyCollectionException( result, "Failed to collect dependencies at " + errorPath ); } if ( !result.getExceptions().isEmpty() ) { throw new DependencyCollectionException( result ); } return result; } DefaultDependencyCollector(); @Inject  DefaultDependencyCollector( RemoteRepositoryManager remoteRepositoryManager,
                                ArtifactDescriptorReader artifactDescriptorReader,
                                VersionRangeResolver versionRangeResolver, LoggerFactory loggerFactory ); void initService( ServiceLocator locator ); DefaultDependencyCollector setLoggerFactory( LoggerFactory loggerFactory ); DefaultDependencyCollector setRemoteRepositoryManager( RemoteRepositoryManager remoteRepositoryManager ); DefaultDependencyCollector setArtifactDescriptorReader( ArtifactDescriptorReader artifactDescriptorReader ); DefaultDependencyCollector setVersionRangeResolver( VersionRangeResolver versionRangeResolver ); CollectResult collectDependencies( RepositorySystemSession session, CollectRequest request ); }
DefaultDependencyCollector implements DependencyCollector, Service { public CollectResult collectDependencies( RepositorySystemSession session, CollectRequest request ) throws DependencyCollectionException { session = optimizeSession( session ); RequestTrace trace = RequestTrace.newChild( request.getTrace(), request ); CollectResult result = new CollectResult( request ); DependencySelector depSelector = session.getDependencySelector(); DependencyManager depManager = session.getDependencyManager(); DependencyTraverser depTraverser = session.getDependencyTraverser(); VersionFilter verFilter = session.getVersionFilter(); Dependency root = request.getRoot(); List<RemoteRepository> repositories = request.getRepositories(); List<Dependency> dependencies = request.getDependencies(); List<Dependency> managedDependencies = request.getManagedDependencies(); Map<String, Object> stats = logger.isDebugEnabled() ? new LinkedHashMap<String, Object>() : null; long time1 = System.currentTimeMillis(); DefaultDependencyNode node; if ( root != null ) { List<? extends Version> versions; VersionRangeResult rangeResult; try { VersionRangeRequest rangeRequest = new VersionRangeRequest( root.getArtifact(), request.getRepositories(), request.getRequestContext() ); rangeRequest.setTrace( trace ); rangeResult = versionRangeResolver.resolveVersionRange( session, rangeRequest ); versions = filterVersions( root, rangeResult, verFilter, new DefaultVersionFilterContext( session ) ); } catch ( VersionRangeResolutionException e ) { result.addException( e ); throw new DependencyCollectionException( result, e.getMessage() ); } Version version = versions.get( versions.size() - 1 ); root = root.setArtifact( root.getArtifact().setVersion( version.toString() ) ); ArtifactDescriptorResult descriptorResult; try { ArtifactDescriptorRequest descriptorRequest = new ArtifactDescriptorRequest(); descriptorRequest.setArtifact( root.getArtifact() ); descriptorRequest.setRepositories( request.getRepositories() ); descriptorRequest.setRequestContext( request.getRequestContext() ); descriptorRequest.setTrace( trace ); if ( isLackingDescriptor( root.getArtifact() ) ) { descriptorResult = new ArtifactDescriptorResult( descriptorRequest ); } else { descriptorResult = descriptorReader.readArtifactDescriptor( session, descriptorRequest ); } } catch ( ArtifactDescriptorException e ) { result.addException( e ); throw new DependencyCollectionException( result, e.getMessage() ); } root = root.setArtifact( descriptorResult.getArtifact() ); if ( !session.isIgnoreArtifactDescriptorRepositories() ) { repositories = remoteRepositoryManager.aggregateRepositories( session, repositories, descriptorResult.getRepositories(), true ); } dependencies = mergeDeps( dependencies, descriptorResult.getDependencies() ); managedDependencies = mergeDeps( managedDependencies, descriptorResult.getManagedDependencies() ); node = new DefaultDependencyNode( root ); node.setRequestContext( request.getRequestContext() ); node.setRelocations( descriptorResult.getRelocations() ); node.setVersionConstraint( rangeResult.getVersionConstraint() ); node.setVersion( version ); node.setAliases( descriptorResult.getAliases() ); node.setRepositories( request.getRepositories() ); } else { node = new DefaultDependencyNode( request.getRootArtifact() ); } result.setRoot( node ); boolean traverse = root == null || depTraverser == null || depTraverser.traverseDependency( root ); String errorPath = null; if ( traverse && !dependencies.isEmpty() ) { DataPool pool = new DataPool( session ); NodeStack nodes = new NodeStack(); nodes.push( node ); DefaultDependencyCollectionContext context = new DefaultDependencyCollectionContext( session, request.getRootArtifact(), root, managedDependencies ); DefaultVersionFilterContext versionContext = new DefaultVersionFilterContext( session ); Args args = new Args( session, trace, pool, nodes, context, versionContext, request ); Results results = new Results( result, session ); process( args, results, dependencies, repositories, depSelector != null ? depSelector.deriveChildSelector( context ) : null, depManager != null ? depManager.deriveChildManager( context ) : null, depTraverser != null ? depTraverser.deriveChildTraverser( context ) : null, verFilter != null ? verFilter.deriveChildFilter( context ) : null ); errorPath = results.errorPath; } long time2 = System.currentTimeMillis(); DependencyGraphTransformer transformer = session.getDependencyGraphTransformer(); if ( transformer != null ) { try { DefaultDependencyGraphTransformationContext context = new DefaultDependencyGraphTransformationContext( session ); context.put( TransformationContextKeys.STATS, stats ); result.setRoot( transformer.transformGraph( node, context ) ); } catch ( RepositoryException e ) { result.addException( e ); } } if ( stats != null ) { long time3 = System.currentTimeMillis(); stats.put( "DefaultDependencyCollector.collectTime", time2 - time1 ); stats.put( "DefaultDependencyCollector.transformTime", time3 - time2 ); logger.debug( "Dependency collection stats: " + stats ); } if ( errorPath != null ) { throw new DependencyCollectionException( result, "Failed to collect dependencies at " + errorPath ); } if ( !result.getExceptions().isEmpty() ) { throw new DependencyCollectionException( result ); } return result; } DefaultDependencyCollector(); @Inject  DefaultDependencyCollector( RemoteRepositoryManager remoteRepositoryManager,
                                ArtifactDescriptorReader artifactDescriptorReader,
                                VersionRangeResolver versionRangeResolver, LoggerFactory loggerFactory ); void initService( ServiceLocator locator ); DefaultDependencyCollector setLoggerFactory( LoggerFactory loggerFactory ); DefaultDependencyCollector setRemoteRepositoryManager( RemoteRepositoryManager remoteRepositoryManager ); DefaultDependencyCollector setArtifactDescriptorReader( ArtifactDescriptorReader artifactDescriptorReader ); DefaultDependencyCollector setVersionRangeResolver( VersionRangeResolver versionRangeResolver ); CollectResult collectDependencies( RepositorySystemSession session, CollectRequest request );  }