mirror of https://github.com/apache/ant-ivy
FIX: add wildcard support for extending configurations (IVY-235): fix problem with import + add junit tests (thanks to Maarten Coene)
git-svn-id: https://svn.apache.org/repos/asf/incubator/ivy/trunk@484318 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
ffa3cf166b
commit
d6df0ce843
|
|
@ -138,6 +138,7 @@ public class XmlModuleDescriptorParser extends AbstractModuleDescriptorParser {
|
|||
URL schemaURL = validate?getClass().getResource("ivy.xsd"):null;
|
||||
XMLHelper.parse(xmlURL, schemaURL, this);
|
||||
checkConfigurations();
|
||||
replaceConfigurationWildcards();
|
||||
if (!_artifactsDeclared) {
|
||||
String[] confs = _md.getConfigurationsNames();
|
||||
for (int i = 0; i < confs.length; i++) {
|
||||
|
|
@ -474,11 +475,9 @@ public class XmlModuleDescriptorParser extends AbstractModuleDescriptorParser {
|
|||
private void checkConfigurations() {
|
||||
if (_md.getConfigurations().length == 0) {
|
||||
_md.addConfiguration(new Configuration("default"));
|
||||
} else {
|
||||
replaceConfigurationWildcards();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void replaceConfigurationWildcards() {
|
||||
Configuration[] configs = _md.getConfigurations();
|
||||
for (int i = 0; i < configs.length; i++) {
|
||||
|
|
|
|||
|
|
@ -533,4 +533,32 @@ public class XmlModuleDescriptorParserTest extends AbstractModuleDescriptorParse
|
|||
assertEquals(Arrays.asList(new String[] {"*"}), Arrays.asList(dd.getDependencyConfigurations("conf1")));
|
||||
}
|
||||
|
||||
public void testExtendOtherConfigs() throws Exception {
|
||||
// import configurations and default mapping
|
||||
ModuleDescriptor md = XmlModuleDescriptorParser.getInstance().parseDescriptor(_ivy, getClass().getResource("test-configextendsothers1.xml"), true);
|
||||
assertNotNull(md);
|
||||
|
||||
// has an 'all-public' configuration
|
||||
Configuration allPublic = md.getConfiguration("all-public");
|
||||
assertNotNull(allPublic);
|
||||
|
||||
// 'all-public' extends all other public configurations
|
||||
String[] allPublicExt = allPublic.getExtends();
|
||||
assertEquals(Arrays.asList(new String[] {"default", "test"}), Arrays.asList(allPublicExt));
|
||||
}
|
||||
|
||||
public void testImportConfigurationsWithExtendOtherConfigs() throws Exception {
|
||||
// import configurations and default mapping
|
||||
ModuleDescriptor md = XmlModuleDescriptorParser.getInstance().parseDescriptor(_ivy, getClass().getResource("test-configextendsothers2.xml"), true);
|
||||
assertNotNull(md);
|
||||
|
||||
// has an 'all-public' configuration
|
||||
Configuration allPublic = md.getConfiguration("all-public");
|
||||
assertNotNull(allPublic);
|
||||
|
||||
// 'all-public' extends all other public configurations
|
||||
String[] allPublicExt = allPublic.getExtends();
|
||||
assertEquals(Arrays.asList(new String[] {"default", "test", "extra"}), Arrays.asList(allPublicExt));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,5 @@
|
|||
<configurations>
|
||||
<conf name="default"/>
|
||||
<conf name="test"/>
|
||||
<conf name="all-public" extends="*(public)" />
|
||||
</configurations>
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
<?xml version="1.0" encoding="ISO-8859-1"?>
|
||||
<?xml-stylesheet type="text/xsl" href="http://www.jayasoft.fr/org/ivyrep/ivy-doc.xsl"?>
|
||||
<ivy-module version="1.0">
|
||||
<info organisation="myorg"
|
||||
module="mymodule"
|
||||
revision="myrev"
|
||||
status="integration"
|
||||
publication="20041101110000"/>
|
||||
<configurations>
|
||||
<conf name="default"/>
|
||||
<conf name="test"/>
|
||||
<conf name="priv" visibility="private" />
|
||||
<conf name="all-public" extends="*(public)" />
|
||||
</configurations>
|
||||
</ivy-module>
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
<?xml version="1.0" encoding="ISO-8859-1"?>
|
||||
<?xml-stylesheet type="text/xsl" href="http://www.jayasoft.fr/org/ivyrep/ivy-doc.xsl"?>
|
||||
<ivy-module version="1.0">
|
||||
<info organisation="myorg"
|
||||
module="mymodule"
|
||||
revision="myrev"
|
||||
status="integration"
|
||||
publication="20041101110000"/>
|
||||
<configurations>
|
||||
<include file="test/java/fr/jayasoft/ivy/xml/imported-configurations-with-wildcard.xml"/>
|
||||
<conf name="priv" visibility="private" />
|
||||
<conf name="extra" />
|
||||
</configurations>
|
||||
</ivy-module>
|
||||
Loading…
Reference in New Issue