ant-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gscok...@apache.org
Subject svn commit: r629619 - in /ant/ivy/core/trunk: ./ src/java/org/apache/ivy/plugins/parser/m2/ test/java/org/apache/ivy/plugins/parser/m2/
Date Wed, 20 Feb 2008 21:35:06 GMT
Author: gscokart
Date: Wed Feb 20 13:35:02 2008
New Revision: 629619

URL: http://svn.apache.org/viewvc?rev=629619&view=rev
Log:
FIX: m2 incompatibility - IVY does not recognize property section(IVY-637)

Added:
    ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/parser/m2/test-parent-properties.pom
  (with props)
Modified:
    ant/ivy/core/trunk/CHANGES.txt
    ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/parser/m2/PomModuleDescriptorBuilder.java
    ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/parser/m2/PomModuleDescriptorParser.java
    ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/parser/m2/PomModuleDescriptorParserTest.java

Modified: ant/ivy/core/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/CHANGES.txt?rev=629619&r1=629618&r2=629619&view=diff
==============================================================================
--- ant/ivy/core/trunk/CHANGES.txt (original)
+++ ant/ivy/core/trunk/CHANGES.txt Wed Feb 20 13:35:02 2008
@@ -101,6 +101,7 @@
 - FIX: Maven test scope includes all runtime dependencies (IVY-682)
 - FIX: Inherit depedencies defined in parent pom (IVY-683)
 - FIX: Incorrect ivy from maven pom generation when classifier are user (IVY-714) (thanks
to Ruslan Shevchenko)
+- FIX: m2 incompatibility - IVY does not recognize property section(IVY-637)
 
 - TASK: Remove cache attribute on Ant tasks (IVY-685)
 

Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/parser/m2/PomModuleDescriptorBuilder.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/parser/m2/PomModuleDescriptorBuilder.java?rev=629619&r1=629618&r2=629619&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/parser/m2/PomModuleDescriptorBuilder.java
(original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/parser/m2/PomModuleDescriptorBuilder.java
Wed Feb 20 13:35:02 2008
@@ -91,7 +91,8 @@
     static final Map MAVEN2_CONF_MAPPING = new HashMap();
 
     private static final String DEPENDENCY_MANAGEMENT = "m:dependency.management";      
 
-    private static final String DEPENDENCY_MANAGEMENT_DELIMITER = "__";
+    private static final String PROPERTIES = "m:properties";
+    private static final String EXTRA_INFO_DELIMITER = "__";
 
     
     static interface ConfMapper {
@@ -247,29 +248,61 @@
 
 
     public void addDependencyMgt(PomDependencyMgt dep) {
-        String key = getDependencyMgtExtraDataKey(dep.getGroupId(), dep.getArtifaceId());
+        String key = getDependencyMgtExtraInfoKey(dep.getGroupId(), dep.getArtifaceId());
         ivyModuleDescriptor.addExtraInfo(key, dep.getVersion());
     }
 
     private String getDefaultVersion(PomDependencyData dep) {
-        String key = getDependencyMgtExtraDataKey(dep.getGroupId(), dep.getArtifaceId());
       
+        String key = getDependencyMgtExtraInfoKey(dep.getGroupId(), dep.getArtifaceId());
       
         return (String) ivyModuleDescriptor.getExtraInfo().get(key);
     }
 
 
-    public static String getDependencyMgtExtraDataKey(String groupId, String artifaceId)
{
-        return DEPENDENCY_MANAGEMENT + DEPENDENCY_MANAGEMENT_DELIMITER + groupId
-                + DEPENDENCY_MANAGEMENT_DELIMITER + artifaceId;
+    private static String getDependencyMgtExtraInfoKey(String groupId, String artifaceId)
{
+        return DEPENDENCY_MANAGEMENT + EXTRA_INFO_DELIMITER + groupId
+                + EXTRA_INFO_DELIMITER + artifaceId;
+    }
+    
+    private static String getPropertyExtraInfoKey(String propertyName) {
+        return PROPERTIES + EXTRA_INFO_DELIMITER + propertyName;
     }
 
+    
 
-    public void addExtraDescription(Map extraAttributes) {
+    public void addExtraInfos(Map extraAttributes) {
         for (Iterator it = extraAttributes.entrySet().iterator(); it.hasNext();) {
-            Map.Entry entry =  (Entry) it.next();
-            if (!ivyModuleDescriptor.getExtraInfo().containsKey(entry.getKey())) {
-                ivyModuleDescriptor.addExtraInfo((String)entry.getKey(), (String)entry.getValue());
+            Map.Entry entry = (Entry) it.next();
+            String key = (String) entry.getKey();
+            String value = (String) entry.getValue();
+            addExtraInfo(key, value);
+        }
+    }
+
+
+    private void addExtraInfo(String key, String value) {
+        if (!ivyModuleDescriptor.getExtraInfo().containsKey(key)) {
+            ivyModuleDescriptor.addExtraInfo(key, value);
+        }
+    }
+
+    
+    
+    public static Map extractPomProperties(Map extraInfo) {
+        Map r = new HashMap();
+        for (Iterator it = extraInfo.entrySet().iterator(); it.hasNext();) {
+            Map.Entry extraInfoEntry = (Map.Entry) it.next();
+            if (((String) extraInfoEntry.getKey()).startsWith(PROPERTIES)) {
+                String prop = ((String) extraInfoEntry.getKey()).substring(PROPERTIES.length()
+                        + EXTRA_INFO_DELIMITER.length());
+                r.put(prop, extraInfoEntry.getValue());
             }
         }
+        return r;
+    }
+
+
+    public void addProperty(String propertyName, String value) {
+        addExtraInfo(getPropertyExtraInfoKey(propertyName), value);
     }
 
     

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=629619&r1=629618&r2=629619&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
Wed Feb 20 13:35:02 2008
@@ -178,9 +178,16 @@
                 for (Iterator iter = pomProperties.entrySet().iterator(); iter.hasNext();)
{
                     Map.Entry prop = (Map.Entry) iter.next();
                     domReader.setProperty((String) prop.getKey(), (String) prop.getValue());
+                    mdBuilder.addProperty((String) prop.getKey(), (String) prop.getValue());
+                }
+                
+                if (parentDescr != null) {
+                    Map parentPomProps = mdBuilder.extractPomProperties(parentDescr.getExtraInfo());
+                    for (Iterator iter = parentPomProps.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();
@@ -188,7 +195,7 @@
                 }
                 
                 if (parentDescr != null) {
-                    mdBuilder.addExtraDescription(parentDescr.getExtraInfo());
+                    mdBuilder.addExtraInfos(parentDescr.getExtraInfo());
                 }
 
                 for (Iterator it = domReader.getDependencies().iterator(); it.hasNext();)
{

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=629619&r1=629618&r2=629619&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
Wed Feb 20 13:35:02 2008
@@ -218,7 +218,7 @@
         assertEquals(extraAtt, dds[0].getAllDependencyArtifacts()[0].getExtraAttributes());
     }
 
-    public void testWithVersionProperty() throws Exception {
+    public void testWithVersionPropertyAndPropertiesTag() throws Exception {
         ModuleDescriptor md = PomModuleDescriptorParser.getInstance().parseDescriptor(
             settings, getClass().getResource("test-version.pom"), false);
         assertNotNull(md);
@@ -510,4 +510,35 @@
         assertEquals(ModuleRevisionId.newInstance("commons-logging", "commons-logging", "1.0.4"),
             dds[1].getDependencyRevisionId());
     }
+
+    public void testParentProperties() throws ParseException, IOException {
+        settings.setDictatorResolver(new MockResolver() {
+            public ResolvedModuleRevision getDependency(DependencyDescriptor dd, ResolveData
data) throws ParseException {
+                try {
+                    ModuleDescriptor moduleDescriptor = PomModuleDescriptorParser.getInstance().parseDescriptor(
+                                            settings, getClass().getResource("test-version.pom"),
false);
+                    return new ResolvedModuleRevision(null,null,moduleDescriptor,null);
+                } catch (IOException e) {
+                    throw new AssertionError(e);
+                }
+            }
+        });
+
+        ModuleDescriptor md = PomModuleDescriptorParser.getInstance().parseDescriptor(
+            settings, getClass().getResource("test-parent-properties.pom"), false);
+        assertNotNull(md);
+
+        DependencyDescriptor[] dds = md.getDependencies();
+        assertNotNull(dds);
+        assertEquals(3, dds.length); 
+        //2 are inherited from parent.  Only the first one is important for this test
+        
+        assertEquals(ModuleRevisionId.newInstance("org.apache", "test-version-other", "5.76"),
dds[0]
+                .getDependencyRevisionId());//present in the pom using a property defined
in the parent
+
+        
+    }
+    
+
+
 }

Added: ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/parser/m2/test-parent-properties.pom
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/parser/m2/test-parent-properties.pom?rev=629619&view=auto
==============================================================================
--- ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/parser/m2/test-parent-properties.pom
(added)
+++ ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/parser/m2/test-parent-properties.pom
Wed Feb 20 13:35:02 2008
@@ -0,0 +1,43 @@
+<?xml version="1.0"?>
+<!--
+   Licensed to the Apache Software Foundation (ASF) under one
+   or more contributor license agreements.  See the NOTICE file
+   distributed with this work for additional information
+   regarding copyright ownership.  The ASF licenses this file
+   to you under the Apache License, Version 2.0 (the
+   "License"); you may not use this file except in compliance
+   with the License.  You may obtain a copy of the License at
+
+     http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing,
+   software distributed under the License is distributed on an
+   "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+   KIND, either express or implied.  See the License for the
+   specific language governing permissions and limitations
+   under the License.    
+-->
+<project>
+  <parent>
+    <artifactId>test-version</artifactId>
+    <groupId>org.apache</groupId>
+    <version>1.0</version>
+  </parent>
+  <modelVersion>4.0.0</modelVersion>
+  <groupId>org.apache</groupId>
+  <artifactId>test</artifactId>
+  <name>Test Module for Ivy M2 parsing</name>
+  <version>1.0</version>
+  <url>http://ivy.jayasoft.org/</url>
+  <organization>
+    <name>Jayasoft</name>
+    <url>http://www.jayasoft.org/</url>
+  </organization>
+  <dependencies>
+	  <dependency>
+	      <groupId>org.apache</groupId>
+	      <artifactId>test-version-other</artifactId>
+	      <version>${test-yet-other-version}</version>
+	  </dependency>
+  </dependencies>
+</project>

Propchange: ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/parser/m2/test-parent-properties.pom
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message