/** * Resolve dependencies and return downloaded information of artifacts. * * @param dependencies the list of dependency * @return downloaded information of artifacts * @throws DependencyResolutionException If the dependency tree could not be built or any dependency * artifact could not be resolved. * @throws ArtifactResolutionException If the artifact could not be resolved. */ public List<ArtifactResult> resolve(List<Dependency> dependencies) throws DependencyResolutionException, ArtifactResolutionException { if (dependencies.size() == 0) { return Collections.EMPTY_LIST; } CollectRequest collectRequest = new CollectRequest(); collectRequest.setRoot(dependencies.get(0)); for (int idx = 1; idx < dependencies.size(); idx++) { collectRequest.addDependency(dependencies.get(idx)); } for (RemoteRepository repository : remoteRepositories) { collectRequest.addRepository(repository); } DependencyFilter classpathFilter = DependencyFilterUtils .classpathFilter(JavaScopes.COMPILE, JavaScopes.RUNTIME); DependencyRequest dependencyRequest = new DependencyRequest(collectRequest, classpathFilter); return system.resolveDependencies(session, dependencyRequest).getArtifactResults(); }
public DependencySelector deriveChildSelector( DependencyCollectionContext context ) { if ( coreArtifact || !isLegacyCoreArtifact( context.getDependency().getArtifact() ) ) { return this; } else { return new WagonExcluder( true ); } }
final CollectRequest collectRequest = new CollectRequest(); collectRequest.setRoot(new Dependency(versionedArtifact, JavaScopes.RUNTIME)); final DependencyRequest dependencyRequest = new DependencyRequest( collectRequest,
DependencyFilter dependencyFilter, List<RemoteRepository> remoteRepositories) throws DependencyCollectionException, DependencyResolutionException { CollectRequest collectRequest = new CollectRequest(); collectRequest.setRoot(root); collectRequest.setDependencies(directDependencies); collectRequest.setManagedDependencies(managedDependencies); collectRequest.setRepositories(resolutionContext.getRemoteRepositories()); if (!collectRequest.getRepositories().contains(authenticatedRemoteRepository)) { collectRequest.addRepository(authenticatedRemoteRepository); try { logger.debug("Collecting dependencies for '{}'", printCollectRequest(collectRequest)); node = repositoryState.getSystem().collectDependencies(repositoryState.getSession(), collectRequest).getRoot(); logDependencyGraph(node, collectRequest); DependencyRequest dependencyRequest = new DependencyRequest();
pluginSession.setDependencyGraphTransformer( transformer ); CollectRequest request = new CollectRequest(); request.setRequestContext( REPOSITORY_CONTEXT ); request.setRepositories( repositories ); request.setRoot( new org.eclipse.aether.graph.Dependency( pluginArtifact, null ) ); for ( Dependency dependency : plugin.getDependencies() ) request.addDependency( pluginDep ); depRequest.setTrace( trace ); request.setTrace( RequestTrace.newChild( trace, depRequest ) ); node = repoSystem.collectDependencies( pluginSession, request ).getRoot();
CollectRequest collect = new CollectRequest(); collect.setRootArtifact( RepositoryUtils.toArtifact( project.getArtifact() ) ); collect.setRequestContext( "project" ); collect.setRepositories( project.getRemoteProjectRepositories() ); collect.addDependency( RepositoryUtils.toDependency( dependency, stereotypes ) ); dep = dep.setArtifact( art ); collect.addDependency( dep ); collect.addManagedDependency( RepositoryUtils.toDependency( dependency, stereotypes ) ); try collect.setTrace( RequestTrace.newChild( trace, depRequest ) ); node = repoSystem.collectDependencies( session, collect ).getRoot(); result.setDependencyGraph( node ); result.setDependencyGraph( e.getResult().getRoot() ); result.setCollectionErrors( e.getResult().getExceptions() ); + project.getId() + ": " + e.getMessage(), e );
urls.add(artifactResult.getArtifact().getFile()); CollectRequest collectRequest = new CollectRequest(); collectRequest.setRoot(new Dependency(artifact, "compile")); for (RemoteRepository remoteRepo : remoteRepositories) { collectRequest.addRepository(remoteRepo); DependencyNode node = REPOSITORY_SYSTEM.collectDependencies(session, collectRequest).getRoot(); DependencyFilter filter = new ExclusionsDependencyFilter(Arrays.asList(excludes)); DependencyRequest dependencyRequest = new DependencyRequest(node, filter);
ArtifactDescriptorResult descriptorResult = mavenPluginRepository.getSystem().readArtifactDescriptor(mavenPluginRepository.getSession(), descriptorRequest); CollectRequest collectRequest = new CollectRequest(); collectRequest.setRootArtifact(descriptorResult.getArtifact()); collectRequest.setDependencies(descriptorResult.getDependencies()); collectRequest.setManagedDependencies(descriptorResult.getManagedDependencies()); collectRequest.setRepositories(descriptorResult.getRepositories()); DependencyNode node = mavenPluginRepository.getSystem().collectDependencies(mavenPluginRepository.getSession(), collectRequest).getRoot(); collectResult.getRoot().accept(nlg); e.printStackTrace(); } catch (ArtifactDescriptorException e2) { e2.printStackTrace();
/** * Creates a request with the specified properties. * * @param root The root dependency whose transitive dependencies should be collected, may be {@code null}. * @param repositories The repositories to use for the collection, may be {@code null}. */ public CollectRequest( Dependency root, List<RemoteRepository> repositories ) { setRoot( root ); setRepositories( repositories ); }
/** * Given a set of maven coordinates, returns a set of jars which include all * of the specified coordinates and optionally their transitive dependencies. */ public Set<File> resolve(boolean withTransitives, Collection<String> mavenCoordinates) { Collection<Exclusion> excludeTransitive = new ArrayList<Exclusion>(1); if (!withTransitives) { excludeTransitive.add(EXCLUDE_ALL_TRANSITIVES); } List<Dependency> dependencies = mavenCoordinates.stream() .map(coordinateString -> new DefaultArtifact(coordinateString)) .map(artifact -> new Dependency(artifact, null, null, excludeTransitive)) .collect(toList()); CollectRequest collectRequest = new CollectRequest(dependencies, null, repositories); DependencyRequest dependencyRequest = new DependencyRequest(collectRequest, null); DependencyResult dependencyResult = resolveDependencies(dependencyRequest); return dependencyResult.getArtifactResults() .stream() .peek(this::logResolved) .map(ArtifactResult::getArtifact) .map(Artifact::getFile) .collect(toSet()); }
private String printCollectRequest(CollectRequest collectRequest) { StringBuilder stringBuilder = new StringBuilder(); stringBuilder.append("["); Iterator<RemoteRepository> iterator = collectRequest.getRepositories().iterator(); while (iterator.hasNext()) { RemoteRepository remoteRepository = iterator.next(); stringBuilder.append(remoteRepository); stringBuilder.append("->authentication["); if (remoteRepository.getAuthentication() != null) { stringBuilder.append(remoteRepository.getAuthentication()); } stringBuilder.append("]"); if (iterator.hasNext()) { stringBuilder.append(", "); } } stringBuilder.append("]"); return collectRequest.getRoot() + " -> " + collectRequest.getDependencies() + " < " + stringBuilder.toString(); }
public void filterVersions( VersionFilterContext context ) throws RepositoryException { for ( int i = 0, n = filters.length; i < n && context.getCount() > 0; i++ ) { filters[i].filterVersions( context ); } }
/** * Creates a new exception with the specified result. * * @param result The collection result at the point the exception occurred, may be {@code null}. */ public DependencyCollectionException( CollectResult result ) { super( "Failed to collect dependencies for " + getSource( result ), getCause( result ) ); this.result = result; }
public DependencyNode transformGraph( DependencyNode node, DependencyGraphTransformationContext context ) throws RepositoryException { for ( DependencyGraphTransformer transformer : transformers ) { node = transformer.transformGraph( node, context ); } return node; }
public boolean selectDependency( Dependency dependency ) { for ( DependencySelector selector : selectors ) { if ( !selector.selectDependency( dependency ) ) { return false; } } return true; }
/** * Creates a new exception with the specified result and detail message. * * @param result The collection result at the point the exception occurred, may be {@code null}. * @param message The detail message, may be {@code null}. */ public DependencyCollectionException( CollectResult result, String message ) { super( message, getCause( result ) ); this.result = result; }
@Override public String toString() { return getRoot() + " -> " + getDependencies() + " < " + getRepositories(); }
public void filterVersions( VersionFilterContext context ) throws RepositoryException { for ( int i = 0, n = filters.length; i < n && context.getCount() > 0; i++ ) { filters[i].filterVersions( context ); } }
/** * Creates a new exception with the specified result. * * @param result The collection result at the point the exception occurred, may be {@code null}. */ public DependencyCollectionException( CollectResult result ) { super( "Failed to collect dependencies for " + getSource( result ), getCause( result ) ); this.result = result; }
/** * Creates a new exception with the specified result and detail message. * * @param result The collection result at the point the exception occurred, may be {@code null}. * @param message The detail message, may be {@code null}. */ public DependencyCollectionException( CollectResult result, String message ) { super( message, getCause( result ) ); this.result = result; }