ant-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hi...@apache.org
Subject [07/35] git commit: FIX: regression introduced by IVY-1457, dependency management wasn't properly handled introducing lots of resolution failures
Date Tue, 28 Oct 2014 21:37:10 GMT
FIX: regression introduced by IVY-1457, dependency management wasn't properly handled introducing
lots of resolution failures

git-svn-id: https://svn.apache.org/repos/asf/ant/ivy/core/trunk@1592624 13f79535-47bb-0310-9956-ffa450edef68


Project: http://git-wip-us.apache.org/repos/asf/ant-ivy/repo
Commit: http://git-wip-us.apache.org/repos/asf/ant-ivy/commit/8d851390
Tree: http://git-wip-us.apache.org/repos/asf/ant-ivy/tree/8d851390
Diff: http://git-wip-us.apache.org/repos/asf/ant-ivy/diff/8d851390

Branch: refs/heads/2.4.x
Commit: 8d851390736dcb916646b043a5ed7ff8f212e37c
Parents: ff2f32b
Author: Jean-Louis Boudart <jlboudart@apache.org>
Authored: Mon May 5 19:52:53 2014 +0000
Committer: Jean-Louis Boudart <jlboudart@apache.org>
Committed: Mon May 5 19:52:53 2014 +0000

----------------------------------------------------------------------
 CHANGES.txt                                     |  1 +
 .../descriptor/DefaultModuleDescriptor.java     | 20 +++++
 .../module/descriptor/ModuleDescriptor.java     | 14 ++++
 .../apache/ivy/osgi/core/BundleInfoAdapter.java |  6 +-
 .../ivy/osgi/repo/AbstractOSGiResolver.java     |  4 +-
 .../parser/m2/PomModuleDescriptorBuilder.java   | 86 ++++++++++++++------
 .../parser/m2/PomModuleDescriptorParser.java    |  4 +-
 .../parser/xml/XmlModuleDescriptorParser.java   |  1 +
 .../m2/PomModuleDescriptorParserTest.java       |  1 +
 .../xml/XmlModuleDescriptorWriterTest.java      | 17 ++++
 .../xml/test-write-extrainfo-from-maven.xml     | 55 +++++++++++++
 11 files changed, 179 insertions(+), 30 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/8d851390/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 8739f80..572a09a 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -146,6 +146,7 @@ for detailed view of each issue, please consult http://issues.apache.org/jira/br
 - IMPROVEMENT: ModuleRules.getRule is O(n) leading to resolution slowness (IVY-1465) (Thanks
to Zhong Wang aka Kewpie)
 
 - FIX: impossible to get artifacts when data has not been loaded. (IVY-1399) (Thanks to David
Turner)
+- FIX: regression introduced by IVY-1457, dependency management wasn't properly handled introducing
lots of resolution failures
 
    2.4.0-rc1
 =====================================

http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/8d851390/src/java/org/apache/ivy/core/module/descriptor/DefaultModuleDescriptor.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/ivy/core/module/descriptor/DefaultModuleDescriptor.java b/src/java/org/apache/ivy/core/module/descriptor/DefaultModuleDescriptor.java
index 43de686..1a62d55 100644
--- a/src/java/org/apache/ivy/core/module/descriptor/DefaultModuleDescriptor.java
+++ b/src/java/org/apache/ivy/core/module/descriptor/DefaultModuleDescriptor.java
@@ -837,10 +837,12 @@ public class DefaultModuleDescriptor implements ModuleDescriptor {
         extraAttributesNamespaces.put(prefix, namespace);
     }
 
+    @Deprecated
     public void addExtraInfo(String infoKey, String value) {
         extraInfo.put(infoKey, value);
     }
 
+    @Deprecated
     public Map getExtraInfo() {
         return extraInfo;
     }
@@ -852,4 +854,22 @@ public class DefaultModuleDescriptor implements ModuleDescriptor {
     public void addExtraInfo(ExtraInfoHolder extraInfo) {
         extraInfos.add(extraInfo);
     }
+
+    public String getExtraInfoContentByTagName(String tagName) {
+        ExtraInfoHolder extraInfoByTagName = getExtraInfoByTagName(tagName);
+        if (extraInfoByTagName != null) {
+            return extraInfoByTagName.getContent();
+        }
+        return null;
+    }
+
+    public ExtraInfoHolder getExtraInfoByTagName(String tagName) {
+        for (ExtraInfoHolder extraInfoHolder : extraInfos) {
+            if (extraInfoHolder.getName().equals(tagName)) {
+                return extraInfoHolder;
+            }
+        }
+        return null;
+
+    }
 }

http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/8d851390/src/java/org/apache/ivy/core/module/descriptor/ModuleDescriptor.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/ivy/core/module/descriptor/ModuleDescriptor.java b/src/java/org/apache/ivy/core/module/descriptor/ModuleDescriptor.java
index fc09715..2cc7049 100644
--- a/src/java/org/apache/ivy/core/module/descriptor/ModuleDescriptor.java
+++ b/src/java/org/apache/ivy/core/module/descriptor/ModuleDescriptor.java
@@ -272,4 +272,18 @@ public interface ModuleDescriptor extends ExtendableItem, ArtifactInfo,
      * @return
      */
     List<ExtraInfoHolder> getExtraInfos();
+
+    /**
+     * Returns content from first extrainfo matching with given tag name
+     * 
+     * @return
+     */
+    String getExtraInfoContentByTagName(String tagName);
+
+    /**
+     * Returns first extrainfo matching with given tag name
+     * 
+     * @return
+     */
+    ExtraInfoHolder getExtraInfoByTagName(String tagName);
 }

http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/8d851390/src/java/org/apache/ivy/osgi/core/BundleInfoAdapter.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/ivy/osgi/core/BundleInfoAdapter.java b/src/java/org/apache/ivy/osgi/core/BundleInfoAdapter.java
index 27a24c0..8f269db 100644
--- a/src/java/org/apache/ivy/osgi/core/BundleInfoAdapter.java
+++ b/src/java/org/apache/ivy/osgi/core/BundleInfoAdapter.java
@@ -39,6 +39,7 @@ import org.apache.ivy.core.module.descriptor.DefaultArtifact;
 import org.apache.ivy.core.module.descriptor.DefaultDependencyDescriptor;
 import org.apache.ivy.core.module.descriptor.DefaultExcludeRule;
 import org.apache.ivy.core.module.descriptor.DefaultModuleDescriptor;
+import org.apache.ivy.core.module.descriptor.ExtraInfoHolder;
 import org.apache.ivy.core.module.id.ArtifactId;
 import org.apache.ivy.core.module.id.ModuleId;
 import org.apache.ivy.core.module.id.ModuleRevisionId;
@@ -98,8 +99,9 @@ public class BundleInfoAdapter {
 
         Set<String> exportedPkgNames = new HashSet<String>(bundle.getExports().size());
         for (ExportPackage exportPackage : bundle.getExports()) {
-            md.getExtraInfo().put(EXTRA_INFO_EXPORT_PREFIX + exportPackage.getName(),
-                exportPackage.getVersion().toString());
+            md.getExtraInfos().add(
+                new ExtraInfoHolder(EXTRA_INFO_EXPORT_PREFIX + exportPackage.getName(),
+                        exportPackage.getVersion().toString()));
             exportedPkgNames.add(exportPackage.getName());
             String[] confDependencies = new String[exportPackage.getUses().size() + 1];
             int i = 0;

http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/8d851390/src/java/org/apache/ivy/osgi/repo/AbstractOSGiResolver.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/ivy/osgi/repo/AbstractOSGiResolver.java b/src/java/org/apache/ivy/osgi/repo/AbstractOSGiResolver.java
index 44c4e0a..45e92ed 100644
--- a/src/java/org/apache/ivy/osgi/repo/AbstractOSGiResolver.java
+++ b/src/java/org/apache/ivy/osgi/repo/AbstractOSGiResolver.java
@@ -197,8 +197,8 @@ public abstract class AbstractOSGiResolver extends BasicResolver {
             ModuleDescriptor md) {
         String org = dd.getDependencyRevisionId().getOrganisation();
         String name = dd.getDependencyRevisionId().getName();
-        String rev = (String) md.getExtraInfo().get(
-            BundleInfoAdapter.EXTRA_INFO_EXPORT_PREFIX + name);
+        String rev = md.getExtraInfoContentByTagName(BundleInfoAdapter.EXTRA_INFO_EXPORT_PREFIX
+                + name);
         ModuleRevisionId capabilityRev = ModuleRevisionId.newInstance(org, name, rev,
             Collections.singletonMap(CAPABILITY_EXTRA_ATTR, md.getModuleRevisionId().toString()));
 

http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/8d851390/src/java/org/apache/ivy/plugins/parser/m2/PomModuleDescriptorBuilder.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/ivy/plugins/parser/m2/PomModuleDescriptorBuilder.java b/src/java/org/apache/ivy/plugins/parser/m2/PomModuleDescriptorBuilder.java
index 0eebff8..3d18b02 100644
--- a/src/java/org/apache/ivy/plugins/parser/m2/PomModuleDescriptorBuilder.java
+++ b/src/java/org/apache/ivy/plugins/parser/m2/PomModuleDescriptorBuilder.java
@@ -41,6 +41,7 @@ import org.apache.ivy.core.module.descriptor.DefaultDependencyDescriptor;
 import org.apache.ivy.core.module.descriptor.DefaultExcludeRule;
 import org.apache.ivy.core.module.descriptor.DefaultModuleDescriptor;
 import org.apache.ivy.core.module.descriptor.DependencyDescriptor;
+import org.apache.ivy.core.module.descriptor.ExtraInfoHolder;
 import org.apache.ivy.core.module.descriptor.License;
 import org.apache.ivy.core.module.descriptor.MDArtifact;
 import org.apache.ivy.core.module.descriptor.ModuleDescriptor;
@@ -367,11 +368,11 @@ public class PomModuleDescriptorBuilder {
         ivyModuleDescriptor.addDependencyManagement(dep);
 
         String key = getDependencyMgtExtraInfoKeyForVersion(dep.getGroupId(), dep.getArtifactId());
-        ivyModuleDescriptor.addExtraInfo(key, dep.getVersion());
+        overwriteExtraInfoIfExists(key, dep.getVersion());
         if (dep.getScope() != null) {
             String scopeKey = getDependencyMgtExtraInfoKeyForScope(dep.getGroupId(),
                 dep.getArtifactId());
-            ivyModuleDescriptor.addExtraInfo(scopeKey, dep.getScope());
+            overwriteExtraInfoIfExists(scopeKey, dep.getScope());
         }
         if (!dep.getExcludedModules().isEmpty()) {
             final String exclusionPrefix = getDependencyMgtExtraInfoPrefixForExclusion(
@@ -379,7 +380,7 @@ public class PomModuleDescriptorBuilder {
             int index = 0;
             for (final Iterator iter = dep.getExcludedModules().iterator(); iter.hasNext();)
{
                 final ModuleId excludedModule = (ModuleId) iter.next();
-                ivyModuleDescriptor.addExtraInfo(
+                overwriteExtraInfoIfExists(
                     exclusionPrefix + index,
                     excludedModule.getOrganisation() + EXTRA_INFO_DELIMITER
                             + excludedModule.getName());
@@ -396,18 +397,25 @@ public class PomModuleDescriptorBuilder {
     public void addPlugin(PomDependencyMgt plugin) {
         String pluginValue = plugin.getGroupId() + EXTRA_INFO_DELIMITER + plugin.getArtifactId()
                 + EXTRA_INFO_DELIMITER + plugin.getVersion();
-        String pluginExtraInfo = (String) ivyModuleDescriptor.getExtraInfo().get("m:maven.plugins");
+        ExtraInfoHolder extraInfoByTagName = ivyModuleDescriptor
+                .getExtraInfoByTagName("m:maven.plugins");
+        if (extraInfoByTagName == null) {
+            extraInfoByTagName = new ExtraInfoHolder();
+            extraInfoByTagName.setName("m:maven.plugins");
+            ivyModuleDescriptor.addExtraInfo(extraInfoByTagName);
+        }
+        String pluginExtraInfo = extraInfoByTagName.getContent();
         if (pluginExtraInfo == null) {
             pluginExtraInfo = pluginValue;
         } else {
             pluginExtraInfo = pluginExtraInfo + "|" + pluginValue;
         }
-        ivyModuleDescriptor.getExtraInfo().put("m:maven.plugins", pluginExtraInfo);
+        extraInfoByTagName.setContent(pluginExtraInfo);
     }
 
     public static List /* <PomDependencyMgt> */getPlugins(ModuleDescriptor md) {
         List result = new ArrayList();
-        String plugins = (String) md.getExtraInfo().get("m:maven.plugins");
+        String plugins = md.getExtraInfoContentByTagName("m:maven.plugins");
         if (plugins == null) {
             return new ArrayList();
         }
@@ -461,7 +469,7 @@ public class PomModuleDescriptorBuilder {
                 moduleId)).getVersion();
         }
         String key = getDependencyMgtExtraInfoKeyForVersion(dep.getGroupId(), dep.getArtifactId());
-        return (String) ivyModuleDescriptor.getExtraInfo().get(key);
+        return ivyModuleDescriptor.getExtraInfoContentByTagName(key);
     }
 
     private String getDefaultScope(PomDependencyData dep) {
@@ -472,7 +480,7 @@ public class PomModuleDescriptorBuilder {
                 moduleId)).getScope();
         } else {
             String key = getDependencyMgtExtraInfoKeyForScope(dep.getGroupId(), dep.getArtifactId());
-            result = (String) ivyModuleDescriptor.getExtraInfo().get(key);
+            result = ivyModuleDescriptor.getExtraInfoContentByTagName(key);
         }
         if ((result == null) || !MAVEN2_CONF_MAPPING.containsKey(result)) {
             result = "compile";
@@ -511,12 +519,10 @@ public class PomModuleDescriptorBuilder {
         }
         String exclusionPrefix = getDependencyMgtExtraInfoPrefixForExclusion(groupId, artifactId);
         List /* <ModuleId> */exclusionIds = new LinkedList /* <ModuleId> */();
-        Map /* <String,String> */extras = descriptor.getExtraInfo();
-        for (final Iterator entIter = extras.entrySet().iterator(); entIter.hasNext();) {
-            Map.Entry /* <String,String> */ent = (Map.Entry) entIter.next();
-            String key = (String) ent.getKey();
+        for (ExtraInfoHolder extraInfoHolder : descriptor.getExtraInfos()) {
+            String key = extraInfoHolder.getName();
             if (key.startsWith(exclusionPrefix)) {
-                String fullExclusion = (String) ent.getValue();
+                String fullExclusion = extraInfoHolder.getContent();
                 String[] exclusionParts = fullExclusion.split(EXTRA_INFO_DELIMITER);
                 if (exclusionParts.length != 2) {
                     Message.error(WRONG_NUMBER_OF_PARTS_MSG + exclusionParts.length + " :
"
@@ -540,16 +546,16 @@ public class PomModuleDescriptorBuilder {
                 ret.put(e.getKey(), dependencyMgt.getVersion());
             }
         } else {
-            for (Iterator iterator = md.getExtraInfo().entrySet().iterator(); iterator.hasNext();)
{
-                Map.Entry entry = (Map.Entry) iterator.next();
-                String key = (String) entry.getKey();
+            for (ExtraInfoHolder extraInfoHolder : md.getExtraInfos()) {
+                String key = extraInfoHolder.getName();
                 if ((key).startsWith(DEPENDENCY_MANAGEMENT)) {
                     String[] parts = key.split(EXTRA_INFO_DELIMITER);
                     if (parts.length != DEPENDENCY_MANAGEMENT_KEY_PARTS_COUNT) {
                         Message.warn("what seem to be a dependency management extra info
"
                                 + "doesn't match expected pattern: " + key);
                     } else {
-                        ret.put(ModuleId.newInstance(parts[1], parts[2]), entry.getValue());
+                        ret.put(ModuleId.newInstance(parts[1], parts[2]),
+                            extraInfoHolder.getContent());
                     }
                 }
             }
@@ -563,9 +569,8 @@ public class PomModuleDescriptorBuilder {
         if (md instanceof PomModuleDescriptor) {
             result.addAll(((PomModuleDescriptor) md).getDependencyManagementMap().values());
         } else {
-            for (Iterator iterator = md.getExtraInfo().entrySet().iterator(); iterator.hasNext();)
{
-                Map.Entry entry = (Map.Entry) iterator.next();
-                String key = (String) entry.getKey();
+            for (ExtraInfoHolder extraInfoHolder : md.getExtraInfos()) {
+                String key = extraInfoHolder.getName();
                 if ((key).startsWith(DEPENDENCY_MANAGEMENT)) {
                     String[] parts = key.split(EXTRA_INFO_DELIMITER);
                     if (parts.length != DEPENDENCY_MANAGEMENT_KEY_PARTS_COUNT) {
@@ -578,8 +583,8 @@ public class PomModuleDescriptorBuilder {
                         String scopeKey = DEPENDENCY_MANAGEMENT + EXTRA_INFO_DELIMITER +
parts[1]
                                 + EXTRA_INFO_DELIMITER + parts[2] + EXTRA_INFO_DELIMITER
+ "scope";
 
-                        String version = (String) md.getExtraInfo().get(versionKey);
-                        String scope = (String) md.getExtraInfo().get(scopeKey);
+                        String version = md.getExtraInfoContentByTagName(versionKey);
+                        String scope = md.getExtraInfoContentByTagName(scopeKey);
 
                         List /* <ModuleId> */exclusions = getDependencyMgtExclusions(md,
parts[1],
                             parts[2]);
@@ -592,6 +597,7 @@ public class PomModuleDescriptorBuilder {
         return result;
     }
 
+    @Deprecated
     public void addExtraInfos(Map extraAttributes) {
         for (Iterator it = extraAttributes.entrySet().iterator(); it.hasNext();) {
             Map.Entry entry = (Entry) it.next();
@@ -602,11 +608,31 @@ public class PomModuleDescriptorBuilder {
     }
 
     private void addExtraInfo(String key, String value) {
-        if (!ivyModuleDescriptor.getExtraInfo().containsKey(key)) {
-            ivyModuleDescriptor.addExtraInfo(key, value);
+        if (ivyModuleDescriptor.getExtraInfoContentByTagName(key) == null) {
+            ivyModuleDescriptor.getExtraInfos().add(new ExtraInfoHolder(key, value));
         }
     }
 
+    private void overwriteExtraInfoIfExists(String key, String value) {
+        boolean found = false;
+        for (ExtraInfoHolder extraInfoHolder : ivyModuleDescriptor.getExtraInfos()) {
+            if (extraInfoHolder.getName().equals(key)) {
+                extraInfoHolder.setContent(value);
+                found = false;
+            }
+        }
+        if (!found) {
+            ivyModuleDescriptor.getExtraInfos().add(new ExtraInfoHolder(key, value));
+        }
+    }
+
+    public void addExtraInfos(List<ExtraInfoHolder> extraInfosHolder) {
+        for (ExtraInfoHolder extraInfoHolder : extraInfosHolder) {
+            addExtraInfo(extraInfoHolder.getName(), extraInfoHolder.getContent());
+        }
+    }
+
+    @Deprecated
     public static Map extractPomProperties(Map extraInfo) {
         Map r = new HashMap();
         for (Iterator it = extraInfo.entrySet().iterator(); it.hasNext();) {
@@ -620,6 +646,18 @@ public class PomModuleDescriptorBuilder {
         return r;
     }
 
+    public static Map extractPomProperties(List<ExtraInfoHolder> extraInfos) {
+        Map r = new HashMap();
+        for (ExtraInfoHolder extraInfoHolder : extraInfos) {
+            if ((extraInfoHolder.getName()).startsWith(PROPERTIES)) {
+                String prop = (extraInfoHolder.getName()).substring(PROPERTIES.length()
+                        + EXTRA_INFO_DELIMITER.length());
+                r.put(prop, extraInfoHolder.getContent());
+            }
+        }
+        return r;
+    }
+
     public void addProperty(String propertyName, String value) {
         addExtraInfo(getPropertyExtraInfoKey(propertyName), value);
     }

http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/8d851390/src/java/org/apache/ivy/plugins/parser/m2/PomModuleDescriptorParser.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/ivy/plugins/parser/m2/PomModuleDescriptorParser.java b/src/java/org/apache/ivy/plugins/parser/m2/PomModuleDescriptorParser.java
index e1274a8..6017e3a 100644
--- a/src/java/org/apache/ivy/plugins/parser/m2/PomModuleDescriptorParser.java
+++ b/src/java/org/apache/ivy/plugins/parser/m2/PomModuleDescriptorParser.java
@@ -144,7 +144,7 @@ public final class PomModuleDescriptorParser implements ModuleDescriptorParser
{
                 }
                 if (parentDescr != null) {
                     Map parentPomProps = PomModuleDescriptorBuilder
-                            .extractPomProperties(parentDescr.getExtraInfo());
+                            .extractPomProperties(parentDescr.getExtraInfos());
                     for (Iterator iter = parentPomProps.entrySet().iterator(); iter.hasNext();)
{
                         Map.Entry prop = (Map.Entry) iter.next();
                         domReader.setProperty((String) prop.getKey(), (String) prop.getValue());
@@ -213,7 +213,7 @@ public final class PomModuleDescriptorParser implements ModuleDescriptorParser
{
                 domReader.setProperty("version", version);
 
                 if (parentDescr != null) {
-                    mdBuilder.addExtraInfos(parentDescr.getExtraInfo());
+                    mdBuilder.addExtraInfos(parentDescr.getExtraInfos());
 
                     // add dependency management info from parent
                     List depMgt = PomModuleDescriptorBuilder.getDependencyManagements(parentDescr);

http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/8d851390/src/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorParser.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorParser.java b/src/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorParser.java
index 800b963..b70f2a3 100644
--- a/src/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorParser.java
+++ b/src/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorParser.java
@@ -563,6 +563,7 @@ public class XmlModuleDescriptorParser extends AbstractModuleDescriptorParser
{
             }
 
             descriptor.getExtraInfo().putAll(parent.getExtraInfo());
+            descriptor.getExtraInfos().addAll(parent.getExtraInfos());
         }
 
         private static String mergeRevisionValue(String inherited, String override) {

http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/8d851390/test/java/org/apache/ivy/plugins/parser/m2/PomModuleDescriptorParserTest.java
----------------------------------------------------------------------
diff --git a/test/java/org/apache/ivy/plugins/parser/m2/PomModuleDescriptorParserTest.java
b/test/java/org/apache/ivy/plugins/parser/m2/PomModuleDescriptorParserTest.java
index 72112ee..d22d6ab 100644
--- a/test/java/org/apache/ivy/plugins/parser/m2/PomModuleDescriptorParserTest.java
+++ b/test/java/org/apache/ivy/plugins/parser/m2/PomModuleDescriptorParserTest.java
@@ -622,6 +622,7 @@ public class PomModuleDescriptorParserTest extends AbstractModuleDescriptorParse
             dds[0].getDependencyRevisionId());
         assertEquals("There is no special artifact when there is no classifier", 0,
             dds[0].getAllDependencyArtifacts().length);
+        assertEquals(4, md.getExtraInfos().size());
     }
 
     public void testDependencyManagmentWithScope() throws ParseException, IOException {

http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/8d851390/test/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorWriterTest.java
----------------------------------------------------------------------
diff --git a/test/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorWriterTest.java
b/test/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorWriterTest.java
index 1382d8e..86d8407 100644
--- a/test/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorWriterTest.java
+++ b/test/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorWriterTest.java
@@ -34,6 +34,8 @@ import org.apache.ivy.core.module.descriptor.ModuleDescriptor;
 import org.apache.ivy.core.module.id.ModuleId;
 import org.apache.ivy.core.module.id.ModuleRevisionId;
 import org.apache.ivy.core.settings.IvySettings;
+import org.apache.ivy.plugins.parser.m2.PomModuleDescriptorParser;
+import org.apache.ivy.plugins.parser.m2.PomModuleDescriptorParserTest;
 import org.apache.ivy.util.FileUtil;
 
 public class XmlModuleDescriptorWriterTest extends TestCase {
@@ -138,6 +140,21 @@ public class XmlModuleDescriptorWriterTest extends TestCase {
         assertEquals(expected, wrote);
     }
 
+    public void testExtraInfosFromMaven() throws Exception {
+        ModuleDescriptor md = PomModuleDescriptorParser.getInstance().parseDescriptor(
+            new IvySettings(),
+            PomModuleDescriptorParserTest.class
+                    .getResource("test-versionPropertyDependencyMgt.pom"), false);
+        XmlModuleDescriptorWriter.write(md, LICENSE, dest);
+
+        assertTrue(dest.exists());
+        String wrote = FileUtil.readEntirely(new BufferedReader(new FileReader(dest)))
+                .replaceAll("\r\n", "\n").replace('\r', '\n');
+        String expected = readEntirely("test-write-extrainfo-from-maven.xml").replaceAll("\r\n",
+            "\n").replace('\r', '\n');
+        assertEquals(expected, wrote);
+    }
+
     public void testExtends() throws Exception {
         ModuleDescriptor md = XmlModuleDescriptorParser.getInstance().parseDescriptor(
             new IvySettings(),

http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/8d851390/test/java/org/apache/ivy/plugins/parser/xml/test-write-extrainfo-from-maven.xml
----------------------------------------------------------------------
diff --git a/test/java/org/apache/ivy/plugins/parser/xml/test-write-extrainfo-from-maven.xml
b/test/java/org/apache/ivy/plugins/parser/xml/test-write-extrainfo-from-maven.xml
new file mode 100644
index 0000000..1c18cd4
--- /dev/null
+++ b/test/java/org/apache/ivy/plugins/parser/xml/test-write-extrainfo-from-maven.xml
@@ -0,0 +1,55 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+   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.    
+-->
+<ivy-module version="2.0" xmlns:m="http://ant.apache.org/ivy/maven">
+	<info organisation="org.apache"
+		module="test-depMgt"
+		revision="1.0"
+		status="release"
+		publication="20140429153143"
+	>
+		<description homepage="http://ivy.jayasoft.org/" />
+		<m:properties__commons.logging.version>1.0.4</m:properties__commons.logging.version>
+		<m:properties__commons.collections.version>1.0.5</m:properties__commons.collections.version>
+		<m:dependency.management__commons-logging__commons-logging__version>1.0.4</m:dependency.management__commons-logging__commons-logging__version>
+		<m:dependency.management__commons-collections__commons-collections__version>1.0.5</m:dependency.management__commons-collections__commons-collections__version>
+		<m:dependency.management__commons-collections__commons-collections__exclusion_0>javax.mail__mail</m:dependency.management__commons-collections__commons-collections__exclusion_0>
+		<m:dependency.management__commons-collections__commons-collections__exclusion_1>javax.jms__jms</m:dependency.management__commons-collections__commons-collections__exclusion_1>
+	</info>
+	<configurations>
+		<conf name="default" visibility="public" description="runtime dependencies and master
artifact can be used with this conf" extends="runtime,master"/>
+		<conf name="master" visibility="public" description="contains only the artifact published
by this module itself, with no transitive dependencies"/>
+		<conf name="compile" visibility="public" description="this is the default scope, used
if none is specified. Compile dependencies are available in all classpaths."/>
+		<conf name="provided" visibility="public" description="this is much like compile, but
indicates you expect the JDK or a container to provide it. It is only available on the compilation
classpath, and is not transitive."/>
+		<conf name="runtime" visibility="public" description="this scope indicates that the
dependency is not required for compilation, but is for execution. It is in the runtime and
test classpaths, but not the compile classpath." extends="compile"/>
+		<conf name="test" visibility="private" description="this scope indicates that the dependency
is not required for normal use of the application, and is only available for the test compilation
and execution phases." extends="runtime"/>
+		<conf name="system" visibility="public" description="this scope is similar to provided
except that you have to provide the JAR which contains it explicitly. The artifact is always
available and is not looked up in a repository."/>
+		<conf name="sources" visibility="public" description="this configuration contains the
source artifact of this module, if any."/>
+		<conf name="javadoc" visibility="public" description="this configuration contains the
javadoc artifact of this module, if any."/>
+		<conf name="optional" visibility="public" description="contains all optional dependencies"/>
+	</configurations>
+	<publications>
+		<artifact name="test-depMgt" type="jar" ext="jar" conf="master"/>
+	</publications>
+	<dependencies>
+		<dependency org="commons-logging" name="commons-logging" rev="1.0.4" force="true" conf="compile->compile(*),master(*);runtime->runtime(*)"/>
+		<override org="commons-logging" module="commons-logging" matcher="exact" rev="1.0.4"/>
+		<override org="commons-collections" module="commons-collections" matcher="exact" rev="1.0.5"/>
+	</dependencies>
+</ivy-module>


Mime
View raw message