/** * Creates a request for the specified dependency graph and with the given resolution filter. * * @param node The root node of the dependency graph whose artifacts should be resolved, may be {@code null}. * @param filter The resolution filter to use, may be {@code null}. */ public DependencyRequest( DependencyNode node, DependencyFilter filter ) { setRoot( node ); setFilter( filter ); }
/** * Creates a request for the specified dependency graph and with the given resolution filter. * * @param node The root node of the dependency graph whose artifacts should be resolved, may be {@code null}. * @param filter The resolution filter to use, may be {@code null}. */ public DependencyRequest( DependencyNode node, DependencyFilter filter ) { setRoot( node ); setFilter( filter ); }
/** * Creates a request for the specified dependency graph and with the given resolution filter. * * @param node The root node of the dependency graph whose artifacts should be resolved, may be {@code null}. * @param filter The resolution filter to use, may be {@code null}. */ public DependencyRequest( DependencyNode node, DependencyFilter filter ) { setRoot( node ); setFilter( filter ); }
public AetherResult resolve(String groupId, String artifactId, String version, String extension, String classifier, List<RemoteRepository> repos) throws PlexusContainerException, ComponentLookupException, DependencyCollectionException, DependencyResolutionException { if (Strings.isBlank(extension) || extension.equals("bundle")) { extension = DEFAULT_EXTENSION; } if (classifier == null) { classifier = DEFAULT_CLASSIFIER; } RepositorySystemSession session = newSession(); Dependency dependency = new Dependency(new DefaultArtifact(groupId, artifactId, classifier, extension, version), "runtime"); CollectRequest collectRequest = new CollectRequest(); collectRequest.setRoot(dependency); RemoteRepository[] repoArray = new RemoteRepository[repos.size()]; repos.toArray(repoArray); for (RemoteRepository repo : repoArray) { collectRequest.addRepository(repo); } RepositorySystem system = getRepositorySystem(); DependencyNode rootNode = system.collectDependencies(session, collectRequest).getRoot(); DependencyRequest dependencyRequest = new DependencyRequest(); dependencyRequest.setRoot(rootNode); system.resolveDependencies(session, dependencyRequest); PreorderNodeListGenerator nlg = new PreorderNodeListGenerator(); rootNode.accept(nlg); return new AetherResult(rootNode, nlg.getFiles(), nlg.getClassPath()); }