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());
}
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);
}
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());
}
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);
}
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());
}
Aggregations