use of org.apache.ivy.core.module.descriptor.Configuration in project ant-ivy by apache.
the class XmlModuleDescriptorWriter method printConfigurations.
private static void printConfigurations(ModuleDescriptor md, PrintWriter out) {
Configuration[] confs = md.getConfigurations();
if (confs.length > 0) {
out.println("\t<configurations>");
for (Configuration conf : confs) {
out.print("\t\t");
printConfiguration(conf, out);
}
out.println("\t</configurations>");
}
}
use of org.apache.ivy.core.module.descriptor.Configuration in project ant-ivy by apache.
the class XmlModuleUpdaterTest method testMergedUpdateWithExtendsAndConfigurationsInheritance.
/**
* Test case for IVY-1437.
*
* @throws Exception if something goes wrong
* @see <a href="https://issues.apache.org/jira/browse/IVY-1437">IVY-1437</a>
*/
@Test
public void testMergedUpdateWithExtendsAndConfigurationsInheritance() throws Exception {
URL url = XmlModuleUpdaterTest.class.getResource("test-extends-configurations-inherit.xml");
XmlModuleDescriptorParser parser = XmlModuleDescriptorParser.getInstance();
ModuleDescriptor md = parser.parseDescriptor(new IvySettings(), url, true);
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
XmlModuleDescriptorUpdater.update(url, buffer, getUpdateOptions("release", "mynewrev").setMerge(true).setMergedDescriptor(md));
ModuleDescriptor updatedMd = parser.parseDescriptor(new IvySettings(), new ByteArrayInputStream(buffer.toByteArray()), new BasicResource("test", false, 0, 0, false), true);
Configuration[] configurations = updatedMd.getConfigurations();
assertNotNull("Configurations shouldn't be null", configurations);
assertEquals("Number of configurations is incorrect", 2, configurations.length);
String updatedXml = buffer.toString();
System.out.println(updatedXml);
assertTrue(updatedXml.contains("configurations defaultconf=\"compile\" defaultconfmapping=\"*->default\""));
assertTrue(updatedXml.contains("dependencies defaultconf=\"compile\" defaultconfmapping=\"*->default\""));
}
use of org.apache.ivy.core.module.descriptor.Configuration in project ant-ivy by apache.
the class XmlModuleUpdaterTest method testMergedUpdateWithInclude.
/**
* Test case for IVY-1315.
*
* @throws Exception if something goes wrong
* @see <a href="https://issues.apache.org/jira/browse/IVY-1315">IVY-1315</a>
*/
@Test
public void testMergedUpdateWithInclude() throws Exception {
URL url = XmlModuleUpdaterTest.class.getResource("test-update-excludedconfs6.xml");
XmlModuleDescriptorParser parser = XmlModuleDescriptorParser.getInstance();
ModuleDescriptor md = parser.parseDescriptor(new IvySettings(), url, true);
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
XmlModuleDescriptorUpdater.update(url, buffer, getUpdateOptions("release", "mynewrev").setMerge(true).setMergedDescriptor(md));
ModuleDescriptor updatedMd = parser.parseDescriptor(new IvySettings(), new ByteArrayInputStream(buffer.toByteArray()), new BasicResource("test", false, 0, 0, false), true);
Configuration[] configurations = updatedMd.getConfigurations();
assertNotNull("Configurations shouldn't be null", configurations);
assertEquals("Number of configurations is incorrect", 6, configurations.length);
String updatedXml = buffer.toString();
System.out.println(updatedXml);
assertTrue(updatedXml.contains("dependencies defaultconf=\"conf1->default\""));
}
use of org.apache.ivy.core.module.descriptor.Configuration in project ant-ivy by apache.
the class XmlModuleUpdaterTest method testUpdateWithExcludeConfigurations1.
@Test
public void testUpdateWithExcludeConfigurations1() throws Exception {
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
URL settingsUrl = new File("test/java/org/apache/ivy/plugins/parser/xml/" + "test-update-excludedconfs1.xml").toURI().toURL();
XmlModuleDescriptorUpdater.update(settingsUrl, buffer, getUpdateOptions("release", "mynewrev").setConfsToExclude(new String[] { "myconf2" }));
XmlModuleDescriptorParser parser = XmlModuleDescriptorParser.getInstance();
ModuleDescriptor updatedMd = parser.parseDescriptor(new IvySettings(), new ByteArrayInputStream(buffer.toByteArray()), new BasicResource("test", false, 0, 0, false), true);
// test the number of configurations
Configuration[] configs = updatedMd.getConfigurations();
assertNotNull("Configurations shouldn't be null", configs);
assertEquals("Number of configurations incorrect", 3, configs.length);
// test that the correct configuration has been removed
assertNull("myconf2 hasn't been removed", updatedMd.getConfiguration("myconf2"));
// test that the other configurations aren't removed
assertNotNull("myconf1 has been removed", updatedMd.getConfiguration("myconf1"));
assertNotNull("myconf3 has been removed", updatedMd.getConfiguration("myconf3"));
assertNotNull("myconf4 has been removed", updatedMd.getConfiguration("myconf4"));
}
use of org.apache.ivy.core.module.descriptor.Configuration in project ant-ivy by apache.
the class ResolveReport method toFixedModuleDescriptor.
public ModuleDescriptor toFixedModuleDescriptor(IvySettings settings, List<ModuleId> midToKeep) {
DefaultModuleDescriptor fixedmd = new DefaultModuleDescriptor(md.getModuleRevisionId(), md.getStatus(), new Date());
// copy namespaces
for (Map.Entry<String, String> ns : md.getExtraAttributesNamespaces().entrySet()) {
fixedmd.addExtraAttributeNamespace(ns.getKey(), ns.getValue());
}
// copy info
fixedmd.setDescription(md.getDescription());
fixedmd.setHomePage(md.getHomePage());
fixedmd.getExtraInfos().addAll(md.getExtraInfos());
// copy configurations
List<String> resolvedConfs = Arrays.asList(getConfigurations());
for (String conf : resolvedConfs) {
fixedmd.addConfiguration(new Configuration(conf));
}
// copy artifacts
for (String conf : resolvedConfs) {
for (Artifact a : md.getArtifacts(conf)) {
fixedmd.addArtifact(conf, a);
}
}
// add resolved dependencies
for (IvyNode dep : dependencies) {
ModuleRevisionId depMrid;
boolean force;
if (midToKeep != null && midToKeep.contains(dep.getModuleId())) {
depMrid = dep.getId();
force = false;
} else {
depMrid = dep.getResolvedId();
force = true;
}
DefaultDependencyDescriptor dd = new DefaultDependencyDescriptor(fixedmd, depMrid, force, false, false);
boolean evicted = true;
for (String rootConf : dep.getRootModuleConfigurations()) {
if (dep.isEvicted(rootConf)) {
continue;
}
evicted = false;
for (String targetConf : dep.getConfigurations(rootConf)) {
dd.addDependencyConfiguration(rootConf, targetConf);
}
}
if (!evicted) {
fixedmd.addDependency(dd);
}
}
return fixedmd;
}
Aggregations