ant-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gscok...@apache.org
Subject svn commit: r629230 - in /ant/ivy/core/trunk: src/java/org/apache/ivy/plugins/parser/m2/ test/java/org/apache/ivy/plugins/parser/m2/
Date Tue, 19 Feb 2008 21:03:40 GMT
Author: gscokart
Date: Tue Feb 19 13:03:21 2008
New Revision: 629230

URL: http://svn.apache.org/viewvc?rev=629230&view=rev
Log:
IVY-637 m2 incompatibility - IVY does not recognize property section (partial fix, the case
of properties inherited from parent is not yet covered

Modified:
    ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/parser/m2/PomModuleDescriptorParser.java
    ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/parser/m2/PomReader.java
    ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/parser/m2/PomModuleDescriptorParserTest.java
    ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/parser/m2/test-version.pom

Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/parser/m2/PomModuleDescriptorParser.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/parser/m2/PomModuleDescriptorParser.java?rev=629230&r1=629229&r2=629230&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/parser/m2/PomModuleDescriptorParser.java
(original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/parser/m2/PomModuleDescriptorParser.java
Tue Feb 19 13:03:21 2008
@@ -24,6 +24,7 @@
 import java.text.ParseException;
 import java.util.Date;
 import java.util.Iterator;
+import java.util.Map;
 
 import org.apache.ivy.core.IvyContext;
 import org.apache.ivy.core.module.descriptor.Artifact;
@@ -172,6 +173,14 @@
                         parentModRevID);
                     parentDescr = parentModule.getDescriptor();
                 }
+                                
+                Map pomProperties = domReader.getPomProperties();
+                for (Iterator iter = pomProperties.entrySet().iterator(); iter.hasNext();)
{
+                    Map.Entry prop = (Map.Entry) iter.next();
+                    domReader.setProperty((String) prop.getKey(), (String) prop.getValue());
+                }
+                //TODO add also the properties to the moduleDescriptor so that it can be
inherited
+                //mdBuilder.addProperty(pomProperties);
                 
                 for (Iterator it = domReader.getDependencyMgt().iterator(); it.hasNext();)
{
                     PomReader.PomDependencyMgt dep = (PomReader.PomDependencyMgt) it.next();

Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/parser/m2/PomReader.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/parser/m2/PomReader.java?rev=629230&r1=629229&r2=629230&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/parser/m2/PomReader.java (original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/parser/m2/PomReader.java Tue Feb 19
13:03:21 2008
@@ -20,7 +20,10 @@
 import java.io.IOException;
 import java.net.URL;
 import java.util.HashMap;
+import java.util.Iterator;
 import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
 
 import org.apache.ivy.core.IvyPatternHelper;
 import org.apache.ivy.core.module.id.ModuleId;
@@ -58,6 +61,7 @@
     private static final String EXCLUSION = "exclusion";
     private static final String DISTRIBUTION_MGT = "distributionManagement";
     private static final String RELOCATION = "relocation";
+    private static final String PROPERTIES = "properties";
     
     
     
@@ -275,12 +279,23 @@
 
     }
     
-    
+    /**
+     * @return the content of the properties tag into the pom.
+     */
+    public Map/* <String,String> */getPomProperties() {
+        Map pomProperties = new HashMap();
+        Element propsEl = getFirstChildElement(projectElement, PROPERTIES);
+        if (propsEl != null) {
+            propsEl.normalize();
+        }
+        for (Iterator it = getAllChilds(propsEl).iterator(); it.hasNext();) {
+            Element prop = (Element) it.next();
+            pomProperties.put(prop.getNodeName(), prop.getTextContent());
+        }
+        return pomProperties;
+    }
     
    
-    
-    
-    
     private String replaceProps(String val) {
         if (val == null) {
             return null;
@@ -315,6 +330,21 @@
         }
         return null;
     }
+    
+    private static List/* <Element> */getAllChilds(Element parent) {
+        List r = new LinkedList();
+        if (parent != null) {
+            NodeList childs = parent.getChildNodes();
+            for (int i = 0; i < childs.getLength(); i++) {
+                Node node = childs.item(i);
+                if (node instanceof Element) {
+                    r.add(node);
+                }
+            }
+        }
+        return r;
+    }
+
 
 
 

Modified: ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/parser/m2/PomModuleDescriptorParserTest.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/parser/m2/PomModuleDescriptorParserTest.java?rev=629230&r1=629229&r2=629230&view=diff
==============================================================================
--- ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/parser/m2/PomModuleDescriptorParserTest.java
(original)
+++ ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/parser/m2/PomModuleDescriptorParserTest.java
Tue Feb 19 13:03:21 2008
@@ -225,8 +225,10 @@
 
         DependencyDescriptor[] dds = md.getDependencies();
         assertNotNull(dds);
-        assertEquals(1, dds.length);
+        assertEquals(2, dds.length);
         assertEquals(ModuleRevisionId.newInstance("org.apache", "test-other", "1.0"), dds[0]
+                .getDependencyRevisionId());
+        assertEquals(ModuleRevisionId.newInstance("org.apache", "test-yet-other", "5.76"),
dds[1]
                 .getDependencyRevisionId());
     }
 

Modified: ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/parser/m2/test-version.pom
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/parser/m2/test-version.pom?rev=629230&r1=629229&r2=629230&view=diff
==============================================================================
--- ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/parser/m2/test-version.pom (original)
+++ ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/parser/m2/test-version.pom Tue Feb
19 13:03:21 2008
@@ -34,5 +34,13 @@
       <artifactId>test-other</artifactId>
       <version>${version}</version>
     </dependency>
+    <dependency>
+      <groupId>org.apache</groupId>
+      <artifactId>test-yet-other</artifactId>
+      <version>${test-yet-other-version}</version>
+    </dependency>
   </dependencies>
+  <properties>
+  	<test-yet-other-version>5.76</test-yet-other-version>
+  </properties>
 </project>



Mime
View raw message