Search in sources :

Example 1 with DefaultMirrorSelector

use of org.sonatype.aether.util.repository.DefaultMirrorSelector 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)

Aggregations

ConsoleDependencyGraphDumper (demo.util.ConsoleDependencyGraphDumper)1 RepositorySystem (org.sonatype.aether.RepositorySystem)1 RepositorySystemSession (org.sonatype.aether.RepositorySystemSession)1 Artifact (org.sonatype.aether.artifact.Artifact)1 CollectRequest (org.sonatype.aether.collection.CollectRequest)1 CollectResult (org.sonatype.aether.collection.CollectResult)1 Dependency (org.sonatype.aether.graph.Dependency)1 RemoteRepository (org.sonatype.aether.repository.RemoteRepository)1 DefaultArtifact (org.sonatype.aether.util.artifact.DefaultArtifact)1 DefaultMirrorSelector (org.sonatype.aether.util.repository.DefaultMirrorSelector)1