Search in sources :

Example 6 with RepositorySystem

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

the class ResolveArtifact method main.

public static void main(String[] args) throws Exception {
    System.out.println("------------------------------------------------------------");
    System.out.println(ResolveArtifact.class.getSimpleName());
    RepositorySystem system = Booter.newRepositorySystem();
    RepositorySystemSession session = Booter.newRepositorySystemSession(system);
    Artifact artifact = new DefaultArtifact("org.sonatype.aether:aether-util:1.9");
    RemoteRepository repo = Booter.newCentralRepository();
    ArtifactRequest artifactRequest = new ArtifactRequest();
    artifactRequest.setArtifact(artifact);
    artifactRequest.addRepository(repo);
    ArtifactResult artifactResult = system.resolveArtifact(session, artifactRequest);
    artifact = artifactResult.getArtifact();
    System.out.println(artifact + " resolved to  " + artifact.getFile());
}
Also used : RepositorySystem(org.sonatype.aether.RepositorySystem) RepositorySystemSession(org.sonatype.aether.RepositorySystemSession) ArtifactRequest(org.sonatype.aether.resolution.ArtifactRequest) RemoteRepository(org.sonatype.aether.repository.RemoteRepository) 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)

Example 7 with RepositorySystem

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

the class FindAvailableVersions method main.

public static void main(String[] args) throws Exception {
    System.out.println("------------------------------------------------------------");
    System.out.println(FindAvailableVersions.class.getSimpleName());
    RepositorySystem system = Booter.newRepositorySystem();
    RepositorySystemSession session = Booter.newRepositorySystemSession(system);
    Artifact artifact = new DefaultArtifact("org.sonatype.aether:aether-util:[0,)");
    RemoteRepository repo = Booter.newCentralRepository();
    VersionRangeRequest rangeRequest = new VersionRangeRequest();
    rangeRequest.setArtifact(artifact);
    rangeRequest.addRepository(repo);
    VersionRangeResult rangeResult = system.resolveVersionRange(session, rangeRequest);
    List<Version> versions = rangeResult.getVersions();
    System.out.println("Available versions " + versions);
}
Also used : RepositorySystem(org.sonatype.aether.RepositorySystem) RepositorySystemSession(org.sonatype.aether.RepositorySystemSession) VersionRangeResult(org.sonatype.aether.resolution.VersionRangeResult) Version(org.sonatype.aether.version.Version) RemoteRepository(org.sonatype.aether.repository.RemoteRepository) VersionRangeRequest(org.sonatype.aether.resolution.VersionRangeRequest) Artifact(org.sonatype.aether.artifact.Artifact) DefaultArtifact(org.sonatype.aether.util.artifact.DefaultArtifact) DefaultArtifact(org.sonatype.aether.util.artifact.DefaultArtifact)

Example 8 with RepositorySystem

use of org.sonatype.aether.RepositorySystem 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)

Example 9 with RepositorySystem

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

the class DefaultServiceLocatorTest method testGetRepositorySystem.

@Test
public void testGetRepositorySystem() {
    DefaultServiceLocator locator = new DefaultServiceLocator();
    locator.addService(ArtifactDescriptorReader.class, StubArtifactDescriptorReader.class);
    locator.addService(VersionResolver.class, StubVersionResolver.class);
    locator.addService(VersionRangeResolver.class, StubVersionRangeResolver.class);
    RepositorySystem repoSys = locator.getService(RepositorySystem.class);
    assertNotNull(repoSys);
}
Also used : RepositorySystem(org.sonatype.aether.RepositorySystem) DefaultServiceLocator(org.sonatype.aether.impl.internal.DefaultServiceLocator) Test(org.junit.Test)

Example 10 with RepositorySystem

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

the class PlexusSupportTest method testExistenceOfPlexusComponentMetadata.

public void testExistenceOfPlexusComponentMetadata() throws Exception {
    getContainer().addComponent(new StubVersionRangeResolver(), VersionRangeResolver.class, null);
    getContainer().addComponent(new StubVersionResolver(), VersionResolver.class, null);
    getContainer().addComponent(new StubArtifactDescriptorReader(), ArtifactDescriptorReader.class, null);
    RepositorySystem repoSystem = lookup(RepositorySystem.class);
    assertNotNull(repoSystem);
    assertSame(repoSystem, lookup(RepositorySystem.class));
    List<LocalRepositoryManagerFactory> lrmfs = getContainer().lookupList(LocalRepositoryManagerFactory.class);
    assertNotNull(lrmfs);
    assertEquals(2, lrmfs.size());
}
Also used : RepositorySystem(org.sonatype.aether.RepositorySystem) LocalRepositoryManagerFactory(org.sonatype.aether.spi.localrepo.LocalRepositoryManagerFactory)

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