You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ivy-commits@incubator.apache.org by ma...@apache.org on 2007/06/11 21:21:02 UTC

svn commit: r546291 - in /incubator/ivy/core/trunk: CHANGES.txt src/java/org/apache/ivy/plugins/parser/m2/PomModuleDescriptorParser.java

Author: maartenc
Date: Mon Jun 11 14:21:01 2007
New Revision: 546291

URL: http://svn.apache.org/viewvc?view=rev&rev=546291
Log:
FIX: pom parser doesn't necessarily processes all important information (IVY-524)

Modified:
    incubator/ivy/core/trunk/CHANGES.txt
    incubator/ivy/core/trunk/src/java/org/apache/ivy/plugins/parser/m2/PomModuleDescriptorParser.java

Modified: incubator/ivy/core/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/CHANGES.txt?view=diff&rev=546291&r1=546290&r2=546291
==============================================================================
--- incubator/ivy/core/trunk/CHANGES.txt (original)
+++ incubator/ivy/core/trunk/CHANGES.txt Mon Jun 11 14:21:01 2007
@@ -57,6 +57,7 @@
 - IMPROVEMENT: Remove @author tags (thanks to Stephane Bailliez)
 - IMPROVEMENT: Remove use of deprecated elements in ivysettings.xml (IVY-505) (with contribution from Jan Materne)
 
+- FIX: pom parser doesn't necessarily processes all important information (IVY-524)
 - FIX: <info> element of Ivy file in cache is not updated when using namespaces (IVY-516)
 - FIX: Retrieve Ant task ignores resolveId attribute (IVY-522) (thanks to Scott Goldstein)
 - FIX: The deprecated "keep" attribute on post resolve tasks causes an error (IVY-517)

Modified: incubator/ivy/core/trunk/src/java/org/apache/ivy/plugins/parser/m2/PomModuleDescriptorParser.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/plugins/parser/m2/PomModuleDescriptorParser.java?view=diff&rev=546291&r1=546290&r2=546291
==============================================================================
--- incubator/ivy/core/trunk/src/java/org/apache/ivy/plugins/parser/m2/PomModuleDescriptorParser.java (original)
+++ incubator/ivy/core/trunk/src/java/org/apache/ivy/plugins/parser/m2/PomModuleDescriptorParser.java Mon Jun 11 14:21:01 2007
@@ -152,6 +152,8 @@
         private DefaultDependencyDescriptor dd;
 
         private Map properties = new HashMap();
+        
+        private StringBuffer buffer = new StringBuffer();
 
         public Parser(ModuleDescriptorParser parser, IvySettings settings, Resource res) {
             super(parser);
@@ -215,10 +217,13 @@
         }
 
         public void endElement(String uri, String localName, String qName) throws SAXException {
-            if (md.getModuleRevisionId() == null && ("project".equals(getContext()))) {
+            processTextContent();
+            
+            String context = getContext();
+            if (md.getModuleRevisionId() == null && ("project".equals(context))) {
                 fillMrid();
             } else if (((organisation != null && module != null && revision != null) || dd != null)
-                    && "project/dependencies/dependency".equals(getContext())) {
+                    && "project/dependencies/dependency".equals(context)) {
                 if (dd == null) {
                     dd = new DefaultDependencyDescriptor(md, ModuleRevisionId.newInstance(
                         organisation, module, revision), true, false, true);
@@ -273,12 +278,12 @@
                 md.addDependency(dd);
                 dd = null;
             } else if ((organisation != null && module != null)
-                   && "project/dependencies/dependency/exclusions/exclusion".equals(getContext())) {
+                   && "project/dependencies/dependency/exclusions/exclusion".equals(context)) {
                 exclusions.add(new ModuleId(organisation, module));
                 organisation = null;
                 module = null;
             }
-            if ("project/dependencies/dependency".equals(getContext())) {
+            if ("project/dependencies/dependency".equals(context)) {
                 organisation = null;
                 module = null;
                 revision = null;
@@ -290,51 +295,62 @@
             contextStack.pop();
         }
 
-        public void characters(char[] ch, int start, int length) throws SAXException {
-            String txt = IvyPatternHelper.substituteVariables(new String(ch, start, length).trim(),
-                properties);
-            if (txt.trim().length() == 0) {
-                return;
-            }
-            String context = getContext();
-            if (context.equals("project/parent/groupId") && organisation == null) {
-                organisation = txt;
-                return;
-            }
-            if (context.equals("project/parent/version") && revision == null) {
-                revision = txt;
-                return;
-            }
-            if (context.equals("project/parent/packaging") && type == null) {
-                type = txt;
-                ext = txt;
-                return;
-            }
-            if (context.startsWith("project/parent")) {
-                return;
-            }
-            if (md.getModuleRevisionId() == null
-                    || context.startsWith("project/dependencies/dependency")) {
-                if (context.equals("project/groupId")) {
-                    organisation = txt;
-                } else if (organisation == null && context.endsWith("groupId")) {
+        private void processTextContent() {
+            if (buffer != null) {
+                String txt = IvyPatternHelper.substituteVariables(buffer.toString(), properties).trim();
+                buffer = null;
+                
+                if (txt.length() == 0) {
+                    return;
+                }
+                
+                String context = getContext();
+                if (context.equals("project/parent/groupId") && organisation == null) {
                     organisation = txt;
-                } else if (module == null && context.endsWith("artifactId")) {
-                    module = txt;
-                } else if (context.equals("project/version")
-                        || (revision == null && context.endsWith("version"))) {
-                    revision = txt;
-                } else if (revision == null && context.endsWith("version")) {
+                    return;
+                }
+                if (context.equals("project/parent/version") && revision == null) {
                     revision = txt;
-                } else if (type == null && context.endsWith("packaging")) {
+                    return;
+                } 
+                if (context.equals("project/parent/packaging") && type == null) {
                     type = txt;
                     ext = txt;
-                } else if (scope == null && context.endsWith("scope")) {
-                    scope = txt;
-                } else if (classifier == null && context.endsWith("dependency/classifier")) {
-                    classifier = txt;
+                    return;
+                } 
+                if (context.startsWith("project/parent")) {
+                    return;
+                } 
+                if (md.getModuleRevisionId() == null
+                        || context.startsWith("project/dependencies/dependency")) {
+                    if (context.equals("project/groupId")) {
+                        organisation = txt;
+                    } else if (organisation == null && context.endsWith("groupId")) {
+                        organisation = txt;
+                    } else if (module == null && context.endsWith("artifactId")) {
+                        module = txt;
+                    } else if (context.equals("project/version")
+                            || (revision == null && context.endsWith("version"))) {
+                        revision = txt;
+                    } else if (revision == null && context.endsWith("version")) {
+                        revision = txt;
+                    } else if (type == null && context.endsWith("packaging")) {
+                        type = txt;
+                        ext = txt;
+                    } else if (scope == null && context.endsWith("scope")) {
+                        scope = txt;
+                    } else if (classifier == null && context.endsWith("dependency/classifier")) {
+                        classifier = txt;
+                    }
                 }
             }
+        }
+
+        public void characters(char[] ch, int start, int length) throws SAXException {
+            if (buffer == null) {
+                buffer = new StringBuffer();
+            }
+            buffer.append(ch, start, length);
         }
 
         private String getContext() {