use of org.sonatype.aether.util.artifact.DefaultArtifact 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.util.artifact.DefaultArtifact 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.util.artifact.DefaultArtifact 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.util.artifact.DefaultArtifact 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, ""));
}
use of org.sonatype.aether.util.artifact.DefaultArtifact in project sonatype-aether by sonatype.
the class EnhancedLocalRepositoryManagerTest method testFindArtifactUsesTimestampedVersion.
@Test
public void testFindArtifactUsesTimestampedVersion() throws Exception {
Artifact artifact = new DefaultArtifact("g.i.d:a.i.d:1.0-SNAPSHOT");
File file = new File(basedir, manager.getPathForLocalArtifact(artifact));
TestFileUtils.write("test", file);
addLocalArtifact(artifact);
artifact = artifact.setVersion("1.0-20110329.221805-4");
LocalArtifactRequest request = new LocalArtifactRequest();
request.setArtifact(artifact);
LocalArtifactResult result = manager.find(session, request);
assertNull(result.toString(), result.getFile());
assertFalse(result.toString(), result.isAvailable());
}
Aggregations