use of org.apache.ivy.core.module.descriptor.DefaultModuleDescriptor in project ant-ivy by apache.
the class ResolveEngine method findModule.
public ResolvedModuleRevision findModule(ModuleRevisionId id, ResolveOptions options) {
DependencyResolver r = settings.getResolver(id);
if (r == null) {
throw new IllegalStateException("no resolver found for " + id.getModuleId());
}
DefaultModuleDescriptor md = DefaultModuleDescriptor.newCallerInstance(id, new String[] { "*" }, false, false);
if (options.getResolveId() == null) {
options.setResolveId(ResolveOptions.getDefaultResolveId(md));
}
try {
return r.getDependency(new DefaultDependencyDescriptor(id, true), new ResolveData(this, options, new ConfigurationResolveReport(this, md, "default", null, options)));
} catch (ParseException e) {
throw new RuntimeException("problem while parsing repository module descriptor for " + id + ": " + e, e);
}
}
use of org.apache.ivy.core.module.descriptor.DefaultModuleDescriptor 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.DefaultModuleDescriptor in project ant-ivy by apache.
the class XmlModuleDescriptorWriterTest method testTransitiveAttributeForNonTransitiveConfs.
/**
* Test that the transitive attribute is written for non-transitive configurations.
*
* <code><conf ... transitive="false" ... /></code>
*
* @throws Exception if something goes wrong
* @see <a href="https://issues.apache.org/jira/browse/IVY-1207">IVY-1207</a>
*/
@Test
public void testTransitiveAttributeForNonTransitiveConfs() throws Exception {
// Given a ModuleDescriptor with a non-transitive configuration
DefaultModuleDescriptor md = new DefaultModuleDescriptor(new ModuleRevisionId(new ModuleId("myorg", "myname"), "1.0"), "integration", new Date());
Configuration conf = new Configuration("conf", PUBLIC, "desc", null, false, null);
md.addConfiguration(conf);
// When the ModuleDescriptor is written
XmlModuleDescriptorWriter.write(md, LICENSE, dest);
// Then the transitive attribute must be set to false
String output = FileUtil.readEntirely(dest);
String writtenConf = output.substring(output.indexOf("<configurations>") + 16, output.indexOf("</configurations>")).trim();
assertTrue("Transitive attribute not set to false: " + writtenConf, writtenConf.contains("transitive=\"false\""));
}
use of org.apache.ivy.core.module.descriptor.DefaultModuleDescriptor in project ant-ivy by apache.
the class XmlModuleDescriptorWriterTest method testInfo.
@Test
public void testInfo() throws Exception {
DefaultModuleDescriptor md = (DefaultModuleDescriptor) XmlModuleDescriptorParser.getInstance().parseDescriptor(new IvySettings(), XmlModuleDescriptorWriterTest.class.getResource("test-info.xml"), true);
md.setResolvedPublicationDate(new GregorianCalendar(2005, 4, 1, 11, 0, 0).getTime());
md.setResolvedModuleRevisionId(new ModuleRevisionId(md.getModuleRevisionId().getModuleId(), "NONE"));
XmlModuleDescriptorWriter.write(md, LICENSE, dest);
assertTrue(dest.exists());
String wrote = FileUtil.readEntirely(new BufferedReader(new FileReader(dest))).replaceAll("\r\n", "\n").replace('\r', '\n');
String expected = readEntirely("test-write-info.xml").replaceAll("\r\n", "\n").replace('\r', '\n');
assertEquals(expected, wrote);
}
use of org.apache.ivy.core.module.descriptor.DefaultModuleDescriptor in project ant-ivy by apache.
the class XmlModuleDescriptorWriterTest method testSimple.
@Test
public void testSimple() throws Exception {
DefaultModuleDescriptor md = (DefaultModuleDescriptor) XmlModuleDescriptorParser.getInstance().parseDescriptor(new IvySettings(), XmlModuleDescriptorWriterTest.class.getResource("test-simple.xml"), true);
md.setResolvedPublicationDate(new GregorianCalendar(2005, 4, 1, 11, 0, 0).getTime());
md.setResolvedModuleRevisionId(new ModuleRevisionId(md.getModuleRevisionId().getModuleId(), "NONE"));
XmlModuleDescriptorWriter.write(md, LICENSE, dest);
assertTrue(dest.exists());
String wrote = FileUtil.readEntirely(new BufferedReader(new FileReader(dest))).replaceAll("\r\n", "\n").replace('\r', '\n');
String expected = readEntirely("test-write-simple.xml").replaceAll("\r\n", "\n").replace('\r', '\n');
assertEquals(expected, wrote);
}
Aggregations