use of org.sonatype.aether.repository.RemoteRepository in project sonatype-aether by sonatype.
the class IniArtifactDescriptorReaderTest method testLookup.
@Test
public void testLookup() throws ArtifactDescriptorException {
StubArtifact art = new StubArtifact("gid:aid:ext:ver");
ArtifactDescriptorRequest request = new ArtifactDescriptorRequest(art, null, "");
ArtifactDescriptorResult description = reader.readArtifactDescriptor(session, request);
assertEquals(request, description.getRequest());
assertEquals(art, description.getArtifact());
assertEquals(1, description.getRelocations().size());
Artifact artifact = description.getRelocations().get(0);
assertEquals("gid", artifact.getGroupId());
assertEquals("aid", artifact.getArtifactId());
assertEquals("ver", artifact.getVersion());
assertEquals("ext", artifact.getExtension());
assertEquals(1, description.getRepositories().size());
RemoteRepository repo = description.getRepositories().get(0);
assertEquals("id", repo.getId());
assertEquals("type", repo.getContentType());
assertEquals("protocol://some/url?for=testing", repo.getUrl());
assertDependencies(description.getDependencies());
assertDependencies(description.getManagedDependencies());
}
use of org.sonatype.aether.repository.RemoteRepository in project sonatype-aether by sonatype.
the class DefaultDeployerTest method setup.
@Before
public void setup() throws IOException {
artifact = new DefaultArtifact("gid", "aid", "jar", "ver");
artifact = artifact.setFile(TestFileUtils.createTempFile("artifact"));
metadata = new DefaultMetadata("gid", "aid", "ver", "type", Nature.RELEASE_OR_SNAPSHOT, TestFileUtils.createTempFile("metadata"));
session = new TestRepositorySystemSession();
manager = new StubRemoteRepositoryManager();
deployer = new DefaultDeployer();
deployer.setRemoteRepositoryManager(manager);
deployer.setRepositoryEventDispatcher(new StubRepositoryEventDispatcher());
UpdateCheckManager updateCheckManager = new StaticUpdateCheckManager(true);
deployer.setUpdateCheckManager(updateCheckManager);
deployer.setFileProcessor(TestFileProcessor.INSTANCE);
deployer.setSyncContextFactory(new StubSyncContextFactory());
request = new DeployRequest();
request.setRepository(new RemoteRepository("id", "default", "file:///"));
connector = new RecordingRepositoryConnector();
manager.setConnector(connector);
listener = new RecordingRepositoryListener();
session.setRepositoryListener(listener);
}
use of org.sonatype.aether.repository.RemoteRepository 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());
}
}
use of org.sonatype.aether.repository.RemoteRepository in project sonatype-aether by sonatype.
the class Aether method resolve.
public AetherResult resolve(String groupId, String artifactId, String version) throws DependencyResolutionException {
RepositorySystemSession session = newSession();
Dependency dependency = new Dependency(new DefaultArtifact(groupId, artifactId, "", "jar", version), "runtime");
RemoteRepository central = new RemoteRepository("central", "default", remoteRepository);
CollectRequest collectRequest = new CollectRequest();
collectRequest.setRoot(dependency);
collectRequest.addRepository(central);
DependencyRequest dependencyRequest = new DependencyRequest();
dependencyRequest.setCollectRequest(collectRequest);
DependencyNode rootNode = repositorySystem.resolveDependencies(session, dependencyRequest).getRoot();
StringBuilder dump = new StringBuilder();
displayTree(rootNode, dump);
PreorderNodeListGenerator nlg = new PreorderNodeListGenerator();
rootNode.accept(nlg);
return new AetherResult(rootNode, nlg.getFiles(), nlg.getClassPath());
}
use of org.sonatype.aether.repository.RemoteRepository in project sonatype-aether by sonatype.
the class EnhancedLocalRepositoryManagerTest method testGetPathForRemoteArtifact.
@Test
public void testGetPathForRemoteArtifact() {
RemoteRepository remoteRepo = new RemoteRepository("repo", "default", "ram:/void");
Artifact artifact = new DefaultArtifact("g.i.d:a.i.d:1.0-SNAPSHOT");
assertEquals("1.0-SNAPSHOT", artifact.getBaseVersion());
assertEquals("g/i/d/a.i.d/1.0-SNAPSHOT/a.i.d-1.0-SNAPSHOT.jar", manager.getPathForRemoteArtifact(artifact, remoteRepo, ""));
artifact = new DefaultArtifact("g.i.d:a.i.d:1.0-20110329.221805-4");
assertEquals("1.0-SNAPSHOT", artifact.getBaseVersion());
assertEquals("g/i/d/a.i.d/1.0-SNAPSHOT/a.i.d-1.0-20110329.221805-4.jar", manager.getPathForRemoteArtifact(artifact, remoteRepo, ""));
}
Aggregations