Search in sources :

Example 11 with RepositorySystem

use of org.sonatype.aether.RepositorySystem in project sonatype-aether by sonatype.

the class ResolveTransitiveDependencies method main.

public static void main(String[] args) throws Exception {
    System.out.println("------------------------------------------------------------");
    System.out.println(ResolveTransitiveDependencies.class.getSimpleName());
    RepositorySystem system = Booter.newRepositorySystem();
    RepositorySystemSession session = Booter.newRepositorySystemSession(system);
    Artifact artifact = new DefaultArtifact("org.sonatype.aether:aether-impl:1.9");
    RemoteRepository repo = Booter.newCentralRepository();
    DependencyFilter classpathFlter = DependencyFilterUtils.classpathFilter(JavaScopes.COMPILE);
    CollectRequest collectRequest = new CollectRequest();
    collectRequest.setRoot(new Dependency(artifact, JavaScopes.COMPILE));
    collectRequest.addRepository(repo);
    DependencyRequest dependencyRequest = new DependencyRequest(collectRequest, classpathFlter);
    List<ArtifactResult> artifactResults = system.resolveDependencies(session, dependencyRequest).getArtifactResults();
    for (ArtifactResult artifactResult : artifactResults) {
        System.out.println(artifactResult.getArtifact() + " resolved to " + artifactResult.getArtifact().getFile());
    }
}
Also used : RepositorySystem(org.sonatype.aether.RepositorySystem) RepositorySystemSession(org.sonatype.aether.RepositorySystemSession) DependencyRequest(org.sonatype.aether.resolution.DependencyRequest) RemoteRepository(org.sonatype.aether.repository.RemoteRepository) DependencyFilter(org.sonatype.aether.graph.DependencyFilter) Dependency(org.sonatype.aether.graph.Dependency) CollectRequest(org.sonatype.aether.collection.CollectRequest) Artifact(org.sonatype.aether.artifact.Artifact) DefaultArtifact(org.sonatype.aether.util.artifact.DefaultArtifact) DefaultArtifact(org.sonatype.aether.util.artifact.DefaultArtifact) ArtifactResult(org.sonatype.aether.resolution.ArtifactResult)

Aggregations

RepositorySystem (org.sonatype.aether.RepositorySystem)11 RepositorySystemSession (org.sonatype.aether.RepositorySystemSession)9 Artifact (org.sonatype.aether.artifact.Artifact)9 DefaultArtifact (org.sonatype.aether.util.artifact.DefaultArtifact)9 RemoteRepository (org.sonatype.aether.repository.RemoteRepository)8 Dependency (org.sonatype.aether.graph.Dependency)4 CollectRequest (org.sonatype.aether.collection.CollectRequest)3 ConsoleDependencyGraphDumper (demo.util.ConsoleDependencyGraphDumper)2 File (java.io.File)2 CollectResult (org.sonatype.aether.collection.CollectResult)2 ArtifactResult (org.sonatype.aether.resolution.ArtifactResult)2 VersionRangeRequest (org.sonatype.aether.resolution.VersionRangeRequest)2 VersionRangeResult (org.sonatype.aether.resolution.VersionRangeResult)2 SubArtifact (org.sonatype.aether.util.artifact.SubArtifact)2 Version (org.sonatype.aether.version.Version)2 Test (org.junit.Test)1 DeployRequest (org.sonatype.aether.deployment.DeployRequest)1 DependencyFilter (org.sonatype.aether.graph.DependencyFilter)1 DefaultServiceLocator (org.sonatype.aether.impl.internal.DefaultServiceLocator)1 InstallRequest (org.sonatype.aether.installation.InstallRequest)1