use of org.apache.ivy.core.module.descriptor.DependencyDescriptor 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.DependencyDescriptor 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.DependencyDescriptor 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.DependencyDescriptor in project ant-ivy by apache.
the class PomModuleDescriptorParserTest method createIvySettingsForParentLicenseTesting.
private IvySettings createIvySettingsForParentLicenseTesting(final String parentPomFileName, final String parentOrgName, final String parentModuleName) throws Exception {
final URL parentPomURL = this.getClass().getResource(parentPomFileName);
assertNotNull("Could not find " + parentPomFileName, parentPomURL);
final PomReader parentPomReader = new PomReader(parentPomURL, new URLResource(parentPomURL));
final License[] parentLicenses = parentPomReader.getLicenses();
assertNotNull("Missing licenses in parent pom " + parentPomFileName, parentLicenses);
assertEquals("Unexpected number of licenses in parent pom " + parentPomFileName, 1, parentLicenses.length);
final DependencyResolver dependencyResolver = new MockedDependencyResolver() {
@Override
protected ModuleDescriptor getModuleDescriptor(DependencyDescriptor dependencyDescriptor) {
final String depOrg = dependencyDescriptor.getDependencyId().getOrganisation();
final String depModuleName = dependencyDescriptor.getDependencyId().getName();
if (depOrg.equals(parentOrgName) && depModuleName.equals(parentModuleName)) {
final DefaultModuleDescriptor moduleDescriptor = DefaultModuleDescriptor.newDefaultInstance(dependencyDescriptor.getDependencyRevisionId());
for (final License license : parentLicenses) {
moduleDescriptor.addLicense(license);
}
return moduleDescriptor;
} else {
return super.getModuleDescriptor(dependencyDescriptor);
}
}
};
final IvySettings ivySettings = new IvySettings();
ivySettings.setDictatorResolver(dependencyResolver);
return ivySettings;
}
use of org.apache.ivy.core.module.descriptor.DependencyDescriptor 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