Search in sources :

Example 21 with CollectRequest

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());
}
Also used : MavenRepositorySystemSession(org.apache.maven.repository.internal.MavenRepositorySystemSession) RepositorySystemSession(org.sonatype.aether.RepositorySystemSession) DependencyRequest(org.sonatype.aether.resolution.DependencyRequest) DependencyNode(org.sonatype.aether.graph.DependencyNode) RemoteRepository(org.sonatype.aether.repository.RemoteRepository) Dependency(org.sonatype.aether.graph.Dependency) CollectRequest(org.sonatype.aether.collection.CollectRequest) PreorderNodeListGenerator(org.sonatype.aether.util.graph.PreorderNodeListGenerator) DefaultArtifact(org.sonatype.aether.util.artifact.DefaultArtifact)

Aggregations

CollectRequest (org.sonatype.aether.collection.CollectRequest)21 CollectResult (org.sonatype.aether.collection.CollectResult)14 Dependency (org.sonatype.aether.graph.Dependency)14 DependencyNode (org.sonatype.aether.graph.DependencyNode)12 Test (org.junit.Test)11 RemoteRepository (org.sonatype.aether.repository.RemoteRepository)10 DefaultArtifact (org.sonatype.aether.util.artifact.DefaultArtifact)8 Artifact (org.sonatype.aether.artifact.Artifact)7 DependencyRequest (org.sonatype.aether.resolution.DependencyRequest)7 DependencyFilter (org.sonatype.aether.graph.DependencyFilter)6 RepositorySystemSession (org.sonatype.aether.RepositorySystemSession)5 PatternExclusionsDependencyFilter (org.sonatype.aether.util.filter.PatternExclusionsDependencyFilter)4 RepositorySystem (org.sonatype.aether.RepositorySystem)3 DependencyCollectionException (org.sonatype.aether.collection.DependencyCollectionException)3 ArtifactDescriptorException (org.sonatype.aether.resolution.ArtifactDescriptorException)3 ConsoleDependencyGraphDumper (demo.util.ConsoleDependencyGraphDumper)2 ArrayList (java.util.ArrayList)1 MojoExecutionException (org.apache.maven.plugin.MojoExecutionException)1 MavenRepositorySystemSession (org.apache.maven.repository.internal.MavenRepositorySystemSession)1 Repository (org.apache.zeppelin.dep.Repository)1