use of org.eclipse.aether.graph.Dependency in project revapi by revapi.
the class ArtifactResolver method collectTransitiveDeps.
protected void collectTransitiveDeps(String gav, Set<Artifact> resolvedArtifacts, Set<Exception> failures) throws RepositoryException {
final Artifact rootArtifact = resolveArtifact(gav);
CollectRequest collectRequest = new CollectRequest(new Dependency(rootArtifact, null), repositories);
DependencyRequest request = new DependencyRequest(collectRequest, null);
DependencyResult result;
try {
result = repositorySystem.resolveDependencies(session, request);
} catch (DependencyResolutionException dre) {
result = dre.getResult();
}
result.getRoot().accept(new TreeDependencyVisitor(new DependencyVisitor() {
@Override
public boolean visitEnter(DependencyNode node) {
return true;
}
@Override
public boolean visitLeave(DependencyNode node) {
Dependency dep = node.getDependency();
if (dep == null || dep.getArtifact().equals(rootArtifact)) {
return true;
}
resolvedArtifacts.add(dep.getArtifact());
return true;
}
}));
failures.addAll(result.getCollectExceptions());
}
use of org.eclipse.aether.graph.Dependency in project activemq-artemis by apache.
the class ArtemisAbstractPlugin method explodeDependencies.
protected List<Artifact> explodeDependencies(Artifact artifact) throws DependencyCollectionException {
final List<Artifact> dependencies = new LinkedList<>();
CollectRequest exploreDependenciesRequest = new CollectRequest(new Dependency(artifact, "compile"), remoteRepos);
CollectResult result = repositorySystem.collectDependencies(repoSession, exploreDependenciesRequest);
final AtomicInteger level = new AtomicInteger(0);
DependencyNode node = result.getRoot();
StringWriter writer = new StringWriter();
final PrintWriter strPrint = new PrintWriter(writer);
strPrint.println("Dependencies explored for " + artifact + ":");
if (node != null) {
node.accept(new DependencyVisitor() {
@Override
public boolean visitEnter(DependencyNode node) {
for (int i = 0; i < level.get(); i++) {
strPrint.print("!...");
}
level.incrementAndGet();
strPrint.println("Dependency:: " + node.getDependency() + " node = " + node.getArtifact());
dependencies.add(node.getArtifact());
return true;
}
@Override
public boolean visitLeave(DependencyNode node) {
level.decrementAndGet();
return true;
}
});
}
getLog().info(writer.toString());
return dependencies;
}
use of org.eclipse.aether.graph.Dependency in project storm by apache.
the class DependencyResolverTest method resolveValid.
@Test
public void resolveValid() throws Exception {
// please pick small artifact which has small transitive dependency
// and let's mark as Ignore if we want to run test even without internet or maven central is often not stable
Dependency dependency = new Dependency(new DefaultArtifact("org.apache.storm:flux-core:1.0.0"), JavaScopes.COMPILE);
List<ArtifactResult> results = sut.resolve(Lists.newArrayList(dependency));
assertTrue(results.size() > 0);
// it should be org.apache.storm:flux-core:jar:1.0.0 and commons-cli:commons-cli:jar:1.2
assertContains(results, "org.apache.storm", "flux-core", "1.0.0");
assertContains(results, "commons-cli", "commons-cli", "1.2");
}
use of org.eclipse.aether.graph.Dependency in project storm by apache.
the class AetherUtilsTest method parseDependency.
@Test
public void parseDependency() throws Exception {
String testDependency = "testgroup:testartifact:1.0.0^testgroup:testexcartifact^testgroup:*";
Dependency dependency = AetherUtils.parseDependency(testDependency);
assertEquals("testgroup", dependency.getArtifact().getGroupId());
assertEquals("testartifact", dependency.getArtifact().getArtifactId());
assertEquals("1.0.0", dependency.getArtifact().getVersion());
assertEquals(JavaScopes.COMPILE, dependency.getScope());
assertEquals(2, dependency.getExclusions().size());
List<Exclusion> exclusions = Lists.newArrayList(dependency.getExclusions());
Exclusion exclusion = exclusions.get(0);
assertEquals("testgroup", exclusion.getGroupId());
assertEquals("testexcartifact", exclusion.getArtifactId());
assertEquals(JavaScopes.COMPILE, dependency.getScope());
exclusion = exclusions.get(1);
assertEquals("testgroup", exclusion.getGroupId());
assertEquals("*", exclusion.getArtifactId());
assertEquals(JavaScopes.COMPILE, dependency.getScope());
}
use of org.eclipse.aether.graph.Dependency in project storm by apache.
the class AetherUtils method parseDependency.
/**
* Parses dependency parameter and build {@link Dependency} object.
*
* @param dependency string representation of dependency parameter
* @return Dependency object
*/
public static Dependency parseDependency(String dependency) {
List<String> dependencyAndExclusions = Arrays.asList(dependency.split("\\^"));
Collection<Exclusion> exclusions = new ArrayList<>();
for (int idx = 1; idx < dependencyAndExclusions.size(); idx++) {
exclusions.add(AetherUtils.createExclusion(dependencyAndExclusions.get(idx)));
}
Artifact artifact = new DefaultArtifact(dependencyAndExclusions.get(0));
return new Dependency(artifact, JavaScopes.COMPILE, false, exclusions);
}
Aggregations