Search in sources :

Example 1 with ConsoleDependencyGraphDumper

use of demo.util.ConsoleDependencyGraphDumper in project sonatype-aether by sonatype.

the class GetDependencyTreeWithMirror method main.

public static void main(String[] args) throws Exception {
    System.out.println("------------------------------------------------------------");
    System.out.println(GetDependencyTreeWithMirror.class.getSimpleName());
    RepositorySystem system = Booter.newRepositorySystem();
    RepositorySystemSession session = Booter.newRepositorySystemSession(system);
    Artifact artifact = new DefaultArtifact("org.apache.maven:maven-aether-provider:3.0.2");
    RemoteRepository central = new RemoteRepository("central", "default", "http://repo1.maven.org/maven2/");
    DefaultMirrorSelector dms = (DefaultMirrorSelector) session.getMirrorSelector();
    dms.add("mirror", "http://repo1.maven.org/maven2/", "default", true, "central", "*");
    CollectRequest collectRequest = new CollectRequest();
    collectRequest.setRoot(new Dependency(artifact, ""));
    collectRequest.addRepository(central);
    CollectResult collectResult = system.collectDependencies(session, collectRequest);
    collectResult.getRoot().accept(new ConsoleDependencyGraphDumper());
}
Also used : RepositorySystem(org.sonatype.aether.RepositorySystem) RepositorySystemSession(org.sonatype.aether.RepositorySystemSession) CollectResult(org.sonatype.aether.collection.CollectResult) RemoteRepository(org.sonatype.aether.repository.RemoteRepository) DefaultMirrorSelector(org.sonatype.aether.util.repository.DefaultMirrorSelector) Dependency(org.sonatype.aether.graph.Dependency) CollectRequest(org.sonatype.aether.collection.CollectRequest) ConsoleDependencyGraphDumper(demo.util.ConsoleDependencyGraphDumper) Artifact(org.sonatype.aether.artifact.Artifact) DefaultArtifact(org.sonatype.aether.util.artifact.DefaultArtifact) DefaultArtifact(org.sonatype.aether.util.artifact.DefaultArtifact)

Example 2 with ConsoleDependencyGraphDumper

use of demo.util.ConsoleDependencyGraphDumper in project sonatype-aether by sonatype.

the class Aether method displayTree.

private void displayTree(DependencyNode node, StringBuilder sb) {
    ByteArrayOutputStream os = new ByteArrayOutputStream(1024);
    node.accept(new ConsoleDependencyGraphDumper(new PrintStream(os)));
    sb.append(os.toString());
}
Also used : PrintStream(java.io.PrintStream) ByteArrayOutputStream(java.io.ByteArrayOutputStream) ConsoleDependencyGraphDumper(demo.util.ConsoleDependencyGraphDumper)

Example 3 with ConsoleDependencyGraphDumper

use of demo.util.ConsoleDependencyGraphDumper in project sonatype-aether by sonatype.

the class GetDependencyTree method main.

public static void main(String[] args) throws Exception {
    System.out.println("------------------------------------------------------------");
    System.out.println(GetDependencyTree.class.getSimpleName());
    RepositorySystem system = Booter.newRepositorySystem();
    RepositorySystemSession session = Booter.newRepositorySystemSession(system);
    Artifact artifact = new DefaultArtifact("org.apache.maven:maven-aether-provider:3.0.2");
    RemoteRepository repo = Booter.newCentralRepository();
    CollectRequest collectRequest = new CollectRequest();
    collectRequest.setRoot(new Dependency(artifact, ""));
    collectRequest.addRepository(repo);
    CollectResult collectResult = system.collectDependencies(session, collectRequest);
    collectResult.getRoot().accept(new ConsoleDependencyGraphDumper());
}
Also used : RepositorySystem(org.sonatype.aether.RepositorySystem) RepositorySystemSession(org.sonatype.aether.RepositorySystemSession) CollectResult(org.sonatype.aether.collection.CollectResult) RemoteRepository(org.sonatype.aether.repository.RemoteRepository) Dependency(org.sonatype.aether.graph.Dependency) CollectRequest(org.sonatype.aether.collection.CollectRequest) ConsoleDependencyGraphDumper(demo.util.ConsoleDependencyGraphDumper) Artifact(org.sonatype.aether.artifact.Artifact) DefaultArtifact(org.sonatype.aether.util.artifact.DefaultArtifact) DefaultArtifact(org.sonatype.aether.util.artifact.DefaultArtifact)

Aggregations

ConsoleDependencyGraphDumper (demo.util.ConsoleDependencyGraphDumper)3 RepositorySystem (org.sonatype.aether.RepositorySystem)2 RepositorySystemSession (org.sonatype.aether.RepositorySystemSession)2 Artifact (org.sonatype.aether.artifact.Artifact)2 CollectRequest (org.sonatype.aether.collection.CollectRequest)2 CollectResult (org.sonatype.aether.collection.CollectResult)2 Dependency (org.sonatype.aether.graph.Dependency)2 RemoteRepository (org.sonatype.aether.repository.RemoteRepository)2 DefaultArtifact (org.sonatype.aether.util.artifact.DefaultArtifact)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 PrintStream (java.io.PrintStream)1 DefaultMirrorSelector (org.sonatype.aether.util.repository.DefaultMirrorSelector)1