You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ant.apache.org by ma...@apache.org on 2009/08/03 08:59:10 UTC

svn commit: r800224 - in /ant/ivy/core/trunk: ./ src/java/org/apache/ivy/plugins/parser/xml/ test/java/org/apache/ivy/plugins/parser/xml/

Author: maartenc
Date: Mon Aug  3 06:59:10 2009
New Revision: 800224

URL: http://svn.apache.org/viewvc?rev=800224&view=rev
Log:
FIX: ivy parse exception when using <publications defaultconf> (IVY-1102)

Modified:
    ant/ivy/core/trunk/CHANGES.txt
    ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorUpdater.java
    ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/parser/xml/XmlModuleUpdaterTest.java
    ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/parser/xml/test-update-excludedconfs4.xml

Modified: ant/ivy/core/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/CHANGES.txt?rev=800224&r1=800223&r2=800224&view=diff
==============================================================================
--- ant/ivy/core/trunk/CHANGES.txt (original)
+++ ant/ivy/core/trunk/CHANGES.txt Mon Aug  3 06:59:10 2009
@@ -93,6 +93,7 @@
 =====================================
 - FIX: URLResource does not properly support authentication (IVY-1106) (thanks to Heschi Kreinick)
 - FIX: Excessive hits to missing URLs uses up all ports on Windows (IVY-1105)
+- FIX: ivy parse exception when using <publications defaultconf> (IVY-1102)
 
    2.1.0-rc2
 =====================================

Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorUpdater.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorUpdater.java?rev=800224&r1=800223&r2=800224&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorUpdater.java (original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorUpdater.java Mon Aug  3 06:59:10 2009
@@ -203,18 +203,19 @@
 
         private String organisation = null;
 
-        private String defaultConfMapping = null; // defaultConfMapping of imported
+        // defaultConfMapping of imported configurations, if any
+        private String defaultConfMapping = null; 
 
-        // configurations, if any
-
-        private Boolean confMappingOverride = null; // confMappingOverride of imported
-
-        // configurations, if any
-
-        private String justOpen = null; // used to know if the last open tag was empty, to
-
-        // adjust termination with /> instead of ></qName>
+        // confMappingOverride of imported configurations, if any
+        private Boolean confMappingOverride = null; 
 
+        // used to know if the last open tag was empty, to adjust termination 
+        // with /> instead of ></qName>
+        private String justOpen = null;
+        
+        // the new value of the defaultconf attribute on the publications tag
+        private String newDefaultConf = null;
+        
         private Stack context = new Stack();
 
         private Stack buffers = new Stack();
@@ -256,8 +257,28 @@
                                 + substitute(settings, attributes.getValue(i)) + "\"");
                     }
                 }
-            } else if ("ivy-module/publications/artifact".equals(getContext())
-                    || "ivy-module/dependencies/dependency/artifact".equals(getContext())) {
+            } else if ("ivy-module/publications/artifact".equals(getContext())) {
+                ExtendedBuffer buffer = new ExtendedBuffer(getContext());
+                buffers.push(buffer);
+                confAttributeBuffers.push(buffer);
+                write("<" + qName);
+                buffer.setDefaultPrint(attributes.getValue("conf") == null
+                        && ((newDefaultConf == null) || (newDefaultConf.length() > 0)));
+                for (int i = 0; i < attributes.getLength(); i++) {
+                    String attName = attributes.getQName(i);
+                    if ("conf".equals(attName)) {
+                        String confName = substitute(settings, attributes.getValue("conf"));
+                        String newConf = removeConfigurationsFromList(confName, confs);
+                        if (newConf.length() > 0) {
+                            write(" " + attributes.getQName(i) + "=\"" + newConf + "\"");
+                            ((ExtendedBuffer) buffers.peek()).setPrint(true);
+                        }
+                    } else {
+                        write(" " + attributes.getQName(i) + "=\""
+                                + substitute(settings, attributes.getValue(i)) + "\"");
+                    }
+                }
+            } else if ("ivy-module/dependencies/dependency/artifact".equals(getContext())) {
                 ExtendedBuffer buffer = new ExtendedBuffer(getContext());
                 buffers.push(buffer);
                 confAttributeBuffers.push(buffer);
@@ -277,6 +298,8 @@
                                 + substitute(settings, attributes.getValue(i)) + "\"");
                     }
                 }
+            } else if ("ivy-module/publications".equals(getContext())) {
+                startPublications(attributes);
             } else {
                 // copy
                 write("<" + qName);
@@ -344,6 +367,23 @@
                 write(" confmappingoverride=\"" + confMappingOverride.toString() + "\"");
             }
         }
+        
+        private void startPublications(Attributes attributes) {
+            write("<publications");
+            for (int i = 0; i < attributes.getLength(); i++) {
+                String attName = attributes.getQName(i);
+                if ("defaultconf".equals(attName)) {
+                    newDefaultConf = removeConfigurationsFromList(substitute(settings,
+                        attributes.getValue("defaultconf")), confs);
+                    if (newDefaultConf.length() > 0) {
+                        write(" " + attributes.getQName(i) + "=\"" + newDefaultConf + "\"");
+                    }
+                } else {
+                    write(" " + attributes.getQName(i) + "=\""
+                            + substitute(settings, attributes.getValue(i)) + "\"");
+                }
+            }
+        }
 
         private void startElementInDependency(Attributes attributes) {
             ExtendedBuffer buffer = new ExtendedBuffer(getContext());

Modified: ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/parser/xml/XmlModuleUpdaterTest.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/parser/xml/XmlModuleUpdaterTest.java?rev=800224&r1=800223&r2=800224&view=diff
==============================================================================
--- ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/parser/xml/XmlModuleUpdaterTest.java (original)
+++ ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/parser/xml/XmlModuleUpdaterTest.java Mon Aug  3 06:59:10 2009
@@ -261,6 +261,8 @@
             + "test-update-excludedconfs4.xml").toURL();
         XmlModuleDescriptorUpdater.update(settingsUrl, buffer, 
             getUpdateOptions("release", "mynewrev").setConfsToExclude(new String[] {"myconf2"}));
+        
+        System.out.println(new String(buffer.toByteArray()));
 
         XmlModuleDescriptorParser parser = XmlModuleDescriptorParser.getInstance();
         ModuleDescriptor updatedMd = parser.parseDescriptor(new IvySettings(),

Modified: ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/parser/xml/test-update-excludedconfs4.xml
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/parser/xml/test-update-excludedconfs4.xml?rev=800224&r1=800223&r2=800224&view=diff
==============================================================================
--- ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/parser/xml/test-update-excludedconfs4.xml (original)
+++ ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/parser/xml/test-update-excludedconfs4.xml Mon Aug  3 06:59:10 2009
@@ -30,7 +30,7 @@
 		<conf name="myconf3" description="desc 3" visibility="private"/>
 		<conf name="myconf4" description="desc 4" />
 	</configurations>
-	<publications>
+	<publications defaultconf="myconf1,myconf2,myconf3">
 		<artifact name="myartifact1" type="jar"/>
 		<artifact name="myartifact2" type="jar" conf="myconf1"/>
 		<artifact name="myartifact3" type="jar" conf="myconf1, myconf2, myconf3"/>