use of org.sonatype.aether.collection.CollectRequest in project sonatype-aether by sonatype.
the class Aether method resolve.
public AetherResult resolve(String groupId, String artifactId, String version) throws DependencyResolutionException {
RepositorySystemSession session = newSession();
Dependency dependency = new Dependency(new DefaultArtifact(groupId, artifactId, "", "jar", version), "runtime");
RemoteRepository central = new RemoteRepository("central", "default", remoteRepository);
CollectRequest collectRequest = new CollectRequest();
collectRequest.setRoot(dependency);
collectRequest.addRepository(central);
DependencyRequest dependencyRequest = new DependencyRequest();
dependencyRequest.setCollectRequest(collectRequest);
DependencyNode rootNode = repositorySystem.resolveDependencies(session, dependencyRequest).getRoot();
StringBuilder dump = new StringBuilder();
displayTree(rootNode, dump);
PreorderNodeListGenerator nlg = new PreorderNodeListGenerator();
rootNode.accept(nlg);
return new AetherResult(rootNode, nlg.getFiles(), nlg.getClassPath());
}
Aggregations