From d6df0ce84312344425d52ce75b90b11f5f964991 Mon Sep 17 00:00:00 2001 From: Xavier Hanin Date: Tue, 2 May 2006 06:51:02 +0000 Subject: [PATCH] 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 --- .../ivy/xml/XmlModuleDescriptorParser.java | 5 ++-- .../xml/XmlModuleDescriptorParserTest.java | 28 +++++++++++++++++++ .../imported-configurations-with-wildcard.xml | 5 ++++ .../ivy/xml/test-configextendsothers1.xml | 15 ++++++++++ .../ivy/xml/test-configextendsothers2.xml | 14 ++++++++++ 5 files changed, 64 insertions(+), 3 deletions(-) create mode 100644 test/java/fr/jayasoft/ivy/xml/imported-configurations-with-wildcard.xml create mode 100644 test/java/fr/jayasoft/ivy/xml/test-configextendsothers1.xml create mode 100644 test/java/fr/jayasoft/ivy/xml/test-configextendsothers2.xml diff --git a/src/java/fr/jayasoft/ivy/xml/XmlModuleDescriptorParser.java b/src/java/fr/jayasoft/ivy/xml/XmlModuleDescriptorParser.java index 6102d92c..ad85c82e 100644 --- a/src/java/fr/jayasoft/ivy/xml/XmlModuleDescriptorParser.java +++ b/src/java/fr/jayasoft/ivy/xml/XmlModuleDescriptorParser.java @@ -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++) { diff --git a/test/java/fr/jayasoft/ivy/xml/XmlModuleDescriptorParserTest.java b/test/java/fr/jayasoft/ivy/xml/XmlModuleDescriptorParserTest.java index 8dfe2eed..beb4d962 100644 --- a/test/java/fr/jayasoft/ivy/xml/XmlModuleDescriptorParserTest.java +++ b/test/java/fr/jayasoft/ivy/xml/XmlModuleDescriptorParserTest.java @@ -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)); + } + } diff --git a/test/java/fr/jayasoft/ivy/xml/imported-configurations-with-wildcard.xml b/test/java/fr/jayasoft/ivy/xml/imported-configurations-with-wildcard.xml new file mode 100644 index 00000000..cc53f151 --- /dev/null +++ b/test/java/fr/jayasoft/ivy/xml/imported-configurations-with-wildcard.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/test/java/fr/jayasoft/ivy/xml/test-configextendsothers1.xml b/test/java/fr/jayasoft/ivy/xml/test-configextendsothers1.xml new file mode 100644 index 00000000..8aabaf57 --- /dev/null +++ b/test/java/fr/jayasoft/ivy/xml/test-configextendsothers1.xml @@ -0,0 +1,15 @@ + + + + + + + + + + + diff --git a/test/java/fr/jayasoft/ivy/xml/test-configextendsothers2.xml b/test/java/fr/jayasoft/ivy/xml/test-configextendsothers2.xml new file mode 100644 index 00000000..69d1bc2c --- /dev/null +++ b/test/java/fr/jayasoft/ivy/xml/test-configextendsothers2.xml @@ -0,0 +1,14 @@ + + + + + + + + + +