use of org.sonatype.aether.graph.Exclusion 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.Exclusion 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.Exclusion in project sonatype-aether by sonatype.
the class DependencyTest method testSetExclusions.
@Test
public void testSetExclusions() {
Dependency d1 = new Dependency(new StubArtifact("gid:aid:ver"), "compile", false, Collections.singleton(new Exclusion("g", "a", "c", "e")));
Dependency d2 = d1.setExclusions(null);
assertNotSame(d2, d1);
assertEquals(0, d2.getExclusions().size());
assertSame(d2, d2.setExclusions(null));
assertSame(d2, d2.setExclusions(Collections.<Exclusion>emptyList()));
assertSame(d2, d2.setExclusions(Collections.<Exclusion>emptySet()));
assertSame(d1, d1.setExclusions(Arrays.asList(new Exclusion("g", "a", "c", "e"))));
Dependency d3 = d1.setExclusions(Arrays.asList(new Exclusion("g", "a", "c", "e"), new Exclusion("g", "a", "c", "f")));
assertNotSame(d3, d1);
assertEquals(2, d3.getExclusions().size());
}
use of org.sonatype.aether.graph.Exclusion in project sonatype-aether by sonatype.
the class IniArtifactDescriptorReaderTest method assertDependencies.
private void assertDependencies(List<Dependency> deps) {
assertEquals(4, deps.size());
Dependency dep = deps.get(0);
assertEquals("scope", dep.getScope());
assertEquals(false, dep.isOptional());
assertEquals(2, dep.getExclusions().size());
Iterator<Exclusion> it = dep.getExclusions().iterator();
Exclusion excl = it.next();
assertEquals("gid3", excl.getGroupId());
assertEquals("aid", excl.getArtifactId());
excl = it.next();
assertEquals("gid2", excl.getGroupId());
assertEquals("aid2", excl.getArtifactId());
Artifact art = dep.getArtifact();
assertEquals("gid", art.getGroupId());
assertEquals("aid", art.getArtifactId());
assertEquals("ver", art.getVersion());
assertEquals("ext", art.getExtension());
dep = deps.get(1);
assertEquals("scope", dep.getScope());
assertEquals(true, dep.isOptional());
assertEquals(0, dep.getExclusions().size());
art = dep.getArtifact();
assertEquals("gid", art.getGroupId());
assertEquals("aid2", art.getArtifactId());
assertEquals("ver", art.getVersion());
assertEquals("ext", art.getExtension());
dep = deps.get(2);
assertEquals("scope", dep.getScope());
assertEquals(true, dep.isOptional());
assertEquals(0, dep.getExclusions().size());
art = dep.getArtifact();
assertEquals("gid", art.getGroupId());
assertEquals("aid", art.getArtifactId());
assertEquals("ver3", art.getVersion());
assertEquals("ext", art.getExtension());
dep = deps.get(3);
assertEquals("scope5", dep.getScope());
assertEquals(true, dep.isOptional());
assertEquals(0, dep.getExclusions().size());
art = dep.getArtifact();
assertEquals("gid1", art.getGroupId());
assertEquals("aid", art.getArtifactId());
assertEquals("ver", art.getVersion());
assertEquals("ext", art.getExtension());
}
use of org.sonatype.aether.graph.Exclusion in project storm by apache.
the class AetherUtilsTest method createExclusion.
@Test
public void createExclusion() throws Exception {
String testExclusion = "group";
Exclusion exclusion = AetherUtils.createExclusion(testExclusion);
assertEquals("group", exclusion.getGroupId());
assertEquals("*", exclusion.getArtifactId());
assertEquals("*", exclusion.getClassifier());
assertEquals("*", exclusion.getExtension());
testExclusion = "group:artifact";
exclusion = AetherUtils.createExclusion(testExclusion);
assertEquals("group", exclusion.getGroupId());
assertEquals("artifact", exclusion.getArtifactId());
assertEquals("*", exclusion.getClassifier());
assertEquals("*", exclusion.getExtension());
testExclusion = "group:artifact:site";
exclusion = AetherUtils.createExclusion(testExclusion);
assertEquals("group", exclusion.getGroupId());
assertEquals("artifact", exclusion.getArtifactId());
assertEquals("site", exclusion.getClassifier());
assertEquals("*", exclusion.getExtension());
testExclusion = "group:artifact:site:jar";
exclusion = AetherUtils.createExclusion(testExclusion);
assertEquals("group", exclusion.getGroupId());
assertEquals("artifact", exclusion.getArtifactId());
assertEquals("site", exclusion.getClassifier());
assertEquals("jar", exclusion.getExtension());
}
Aggregations