use of org.apache.ivy.core.module.descriptor.ModuleDescriptor in project ant-ivy by apache.
the class PomModuleDescriptorParserTest method testDependenciesWithScope.
@Test
public void testDependenciesWithScope() throws Exception {
ModuleDescriptor md = PomModuleDescriptorParser.getInstance().parseDescriptor(settings, getClass().getResource("test-dependencies-with-scope.pom"), false);
assertNotNull(md);
assertEquals(ModuleRevisionId.newInstance("org.apache", "test", "1.0"), md.getModuleRevisionId());
DependencyDescriptor[] dds = md.getDependencies();
assertNotNull(dds);
assertEquals(3, dds.length);
assertEquals(ModuleRevisionId.newInstance("odmg", "odmg", "3.0"), dds[0].getDependencyRevisionId());
assertEquals(new HashSet<>(Collections.singletonList("runtime")), new HashSet<>(Arrays.asList(dds[0].getModuleConfigurations())));
assertEquals(new HashSet<>(Arrays.asList("compile(*)", "runtime(*)", "master(*)")), new HashSet<>(Arrays.asList(dds[0].getDependencyConfigurations("runtime"))));
assertEquals(ModuleRevisionId.newInstance("commons-logging", "commons-logging", "1.0.4"), dds[1].getDependencyRevisionId());
assertEquals(new HashSet<>(Arrays.asList("compile", "runtime")), new HashSet<>(Arrays.asList(dds[1].getModuleConfigurations())));
assertEquals(new HashSet<>(Arrays.asList("master(*)", "compile(*)")), new HashSet<>(Arrays.asList(dds[1].getDependencyConfigurations("compile"))));
assertEquals(new HashSet<>(Collections.singletonList("runtime(*)")), new HashSet<>(Arrays.asList(dds[1].getDependencyConfigurations("runtime"))));
assertEquals(ModuleRevisionId.newInstance("cglib", "cglib", "2.0.2"), dds[2].getDependencyRevisionId());
assertEquals(new HashSet<>(Arrays.asList("compile", "runtime")), new HashSet<>(Arrays.asList(dds[2].getModuleConfigurations())));
assertEquals(new HashSet<>(Arrays.asList("master(*)", "compile(*)")), new HashSet<>(Arrays.asList(dds[2].getDependencyConfigurations("compile"))));
assertEquals(new HashSet<>(Collections.singletonList("runtime(*)")), new HashSet<>(Arrays.asList(dds[2].getDependencyConfigurations("runtime"))));
}
use of org.apache.ivy.core.module.descriptor.ModuleDescriptor in project ant-ivy by apache.
the class PomModuleDescriptorParserTest method testParentBomImport.
@Test
public void testParentBomImport() throws ParseException, IOException {
settings.setDictatorResolver(new MockResolver() {
public ResolvedModuleRevision getDependency(DependencyDescriptor dd, ResolveData data) throws ParseException {
try {
ModuleDescriptor moduleDescriptor = PomModuleDescriptorParser.getInstance().parseDescriptor(settings, getClass().getResource(String.format("depmgt/%s.pom", dd.getDependencyId().getName())), false);
return new ResolvedModuleRevision(null, null, moduleDescriptor, null);
} catch (IOException e) {
throw new AssertionError(e);
}
}
});
ModuleDescriptor md = PomModuleDescriptorParser.getInstance().parseDescriptor(settings, getClass().getResource("depmgt/child.pom"), false);
assertNotNull(md);
assertEquals("1.0", md.getRevision());
DependencyDescriptor[] dds = md.getDependencies();
assertNotNull(dds);
assertEquals(1, dds.length);
assertEquals(ModuleRevisionId.newInstance("commons-logging", "commons-logging", "1.0.4"), dds[0].getDependencyRevisionId());
}
use of org.apache.ivy.core.module.descriptor.ModuleDescriptor in project ant-ivy by apache.
the class PomModuleDescriptorParserTest method testEjbType.
@Test
public void testEjbType() throws Exception {
ModuleDescriptor md = PomModuleDescriptorParser.getInstance().parseDescriptor(settings, getClass().getResource("test-ejb-type.pom"), false);
assertNotNull(md);
ModuleRevisionId mrid = ModuleRevisionId.newInstance("org.apache", "test-ejb-type", "1.0");
assertEquals(mrid, md.getModuleRevisionId());
DependencyDescriptor[] deps = md.getDependencies();
assertNotNull(deps);
assertEquals(1, deps.length);
DependencyArtifactDescriptor[] artifacts = deps[0].getAllDependencyArtifacts();
assertNotNull(artifacts);
assertEquals(1, artifacts.length);
assertEquals("test", artifacts[0].getName());
assertEquals("jar", artifacts[0].getExt());
assertEquals("ejb", artifacts[0].getType());
}
use of org.apache.ivy.core.module.descriptor.ModuleDescriptor in project ant-ivy by apache.
the class PomModuleDescriptorParserTest method testDependencyManagementWithScope.
@Test
public void testDependencyManagementWithScope() throws ParseException, IOException {
ModuleDescriptor md = PomModuleDescriptorParser.getInstance().parseDescriptor(settings, getClass().getResource("test-dependencyMgt-with-scope.pom"), false);
assertNotNull(md);
assertEquals(ModuleRevisionId.newInstance("org.apache", "test-depMgt", "1.1"), md.getModuleRevisionId());
DependencyDescriptor[] dds = md.getDependencies();
assertNotNull(dds);
assertEquals(1, dds.length);
assertEquals(ModuleRevisionId.newInstance("commons-logging", "commons-logging", "1.0.4"), dds[0].getDependencyRevisionId());
assertEquals("There is no special artifact when there is no classifier", 0, dds[0].getAllDependencyArtifacts().length);
assertEquals("The number of configurations is incorrect", 1, dds[0].getModuleConfigurations().length);
assertEquals("The configuration must be test", "test", dds[0].getModuleConfigurations()[0]);
}
use of org.apache.ivy.core.module.descriptor.ModuleDescriptor in project ant-ivy by apache.
the class PomModuleDescriptorParserTest method testOverrideGrandparentProperties.
@Test
public void testOverrideGrandparentProperties() throws ParseException, IOException {
settings.setDictatorResolver(new MockResolver() {
public ResolvedModuleRevision getDependency(DependencyDescriptor dd, ResolveData data) throws ParseException {
String resource;
if ("test".equals(dd.getDependencyId().getName())) {
resource = "test-parent-properties.pom";
} else {
resource = "test-version.pom";
}
try {
ModuleDescriptor moduleDescriptor = PomModuleDescriptorParser.getInstance().parseDescriptor(settings, getClass().getResource(resource), false);
return new ResolvedModuleRevision(null, null, moduleDescriptor, null);
} catch (IOException e) {
throw new AssertionError(e);
}
}
});
ModuleDescriptor md = PomModuleDescriptorParser.getInstance().parseDescriptor(settings, getClass().getResource("test-override-grandparent-properties.pom"), false);
assertNotNull(md);
assertEquals("1.0", md.getRevision());
DependencyDescriptor[] dds = md.getDependencies();
assertNotNull(dds);
assertEquals(3, dds.length);
assertEquals(ModuleRevisionId.newInstance("org.apache", "test-version-other", "5.79"), dds[0].getDependencyRevisionId());
assertEquals(ModuleRevisionId.newInstance("org.apache", "test-yet-other", "5.79"), dds[2].getDependencyRevisionId());
}
Aggregations