use of org.sonatype.aether.graph.Dependency in project storm by apache.
the class AetherUtils method parseDependency.
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);
}
use of org.sonatype.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.sonatype.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.sonatype.aether.graph.Dependency 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);
}
}
use of org.sonatype.aether.graph.Dependency in project sonatype-aether by sonatype.
the class PatternInclusionsDependencyFilter method accept.
public boolean accept(final DependencyNode node, List<DependencyNode> parents) {
final Dependency dependency = node.getDependency();
if (dependency == null) {
return true;
}
final Artifact artifact = dependency.getArtifact();
for (final String pattern : patterns) {
final boolean matched = accept(artifact, pattern);
if (matched) {
return true;
}
}
return false;
}
Aggregations