use of org.sonatype.aether.collection.CollectRequest in project sonatype-aether by sonatype.
the class DefaultDependencyCollectorTest method testDependencyManagement.
@Test
public void testDependencyManagement() throws IOException, DependencyCollectionException {
collector.setArtifactDescriptorReader(new IniArtifactDescriptorReader("artifact-descriptions/managed/"));
DependencyNode root = parser.parse("expectedSubtreeComparisonResult.txt");
TestDependencyManager depMgmt = new TestDependencyManager();
depMgmt.addManagedDependency(dep(root, 0), "managed", null, null);
depMgmt.addManagedDependency(dep(root, 0, 1), "managed", "managed", null);
depMgmt.addManagedDependency(dep(root, 1), null, null, "managed");
session.setDependencyManager(depMgmt);
// collect result will differ from expectedSubtreeComparisonResult.txt
// set localPath -> no dependency traversal
CollectRequest request = new CollectRequest(dep(root), Arrays.asList(repository));
CollectResult result = collector.collectDependencies(session, request);
DependencyNode node = result.getRoot();
assertEquals("managed", dep(node, 0, 1).getArtifact().getVersion());
assertEquals("managed", dep(node, 0, 1).getScope());
assertEquals("managed", dep(node, 1).getArtifact().getProperty(ArtifactProperties.LOCAL_PATH, null));
assertEquals("managed", dep(node, 0, 0).getArtifact().getProperty(ArtifactProperties.LOCAL_PATH, null));
}
use of org.sonatype.aether.collection.CollectRequest in project sonatype-aether by sonatype.
the class DefaultDependencyCollectorTest method testCyclicDependencies.
@Test
public void testCyclicDependencies() throws Exception {
DependencyNode root = parser.parse("cycle.txt");
CollectRequest request = new CollectRequest(root.getDependency(), Arrays.asList(repository));
CollectResult result = collector.collectDependencies(session, request);
assertEqualSubtree(root, result.getRoot());
}
use of org.sonatype.aether.collection.CollectRequest in project sonatype-aether by sonatype.
the class DefaultDependencyCollectorTest method testCyclicDependenciesBig.
@Test
public void testCyclicDependenciesBig() throws Exception {
DependencyNode root = parser.parse("cycle-big.txt");
CollectRequest request = new CollectRequest(root.getDependency(), Arrays.asList(repository));
collector.setArtifactDescriptorReader(new IniArtifactDescriptorReader("artifact-descriptions/cycle-big/"));
CollectResult result = collector.collectDependencies(session, request);
assertNotNull(result.getRoot());
// we only care about the performance here, this test must not hang or run out of mem
}
use of org.sonatype.aether.collection.CollectRequest 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());
}
use of org.sonatype.aether.collection.CollectRequest in project karaf by apache.
the class Dependency30Helper method getDependencyTree.
private DependencyNode getDependencyTree(Artifact artifact) throws MojoExecutionException {
try {
CollectRequest collectRequest = new CollectRequest(new Dependency(artifact, "compile"), null, projectRepositories);
DefaultRepositorySystemSession session = new DefaultRepositorySystemSession(repositorySystemSession);
session.setDependencySelector(new AndDependencySelector(new OptionalDependencySelector(), new ScopeDependencySelector1(), new ExclusionDependencySelector()));
DependencyGraphTransformer transformer = new ChainedDependencyGraphTransformer(new ConflictMarker(), new JavaEffectiveScopeCalculator(), new JavaDependencyContextRefiner());
session.setDependencyGraphTransformer(transformer);
CollectResult result = repositorySystem.collectDependencies(session, collectRequest);
return result.getRoot();
} catch (DependencyCollectionException e) {
throw new MojoExecutionException("Cannot build project dependency tree", e);
}
}
Aggregations