ant-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From maart...@apache.org
Subject svn commit: r1376738 - in /ant/ivy/core/trunk: ./ src/java/org/apache/ivy/osgi/core/ src/java/org/apache/ivy/plugins/latest/ src/java/org/apache/ivy/plugins/parser/xml/ src/java/org/apache/ivy/plugins/resolver/ src/java/org/apache/ivy/plugins/version/ ...
Date Thu, 23 Aug 2012 22:21:00 GMT
Author: maartenc
Date: Thu Aug 23 22:21:00 2012
New Revision: 1376738

URL: http://svn.apache.org/viewvc?rev=1376738&view=rev
Log:
FIX: Ivy descriptors are merged incorrectly when there is an <exclude> element (IVY-1356)

Added:
    ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/parser/xml/test-extends-dependencies-exclude.xml
Modified:
    ant/ivy/core/trunk/CHANGES.txt
    ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/core/OsgiLatestStrategy.java
    ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/latest/LatestRevisionStrategy.java
    ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorUpdater.java
    ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/DependencyResolver.java
    ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/version/LatestVersionMatcher.java
    ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/parser/xml/XmlModuleUpdaterTest.java

Modified: ant/ivy/core/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/CHANGES.txt?rev=1376738&r1=1376737&r2=1376738&view=diff
==============================================================================
--- ant/ivy/core/trunk/CHANGES.txt (original)
+++ ant/ivy/core/trunk/CHANGES.txt Thu Aug 23 22:21:00 2012
@@ -130,6 +130,7 @@ for detailed view of each issue, please 
 	
    trunk
 =====================================
+- FIX: Ivy descriptors are merged incorrectly when there is an <exclude> element (IVY-1356)
 - FIX: SimpleDateFormat is not thread safe (IVY-1373)
 - FIX: Maven 'hk2-jar' packaging is now supported (IVY-1357)
 - FIX: Maven 'orbit' and 'pear' packaging is now supported (IVY-899)

Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/core/OsgiLatestStrategy.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/core/OsgiLatestStrategy.java?rev=1376738&r1=1376737&r2=1376738&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/core/OsgiLatestStrategy.java (original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/core/OsgiLatestStrategy.java Thu Aug 23
22:21:00 2012
@@ -71,7 +71,10 @@ public class OsgiLatestStrategy extends 
             VersionMatcher vmatcher = IvyContext.getContext().getSettings().getVersionMatcher();
             ModuleRevisionId mrid1 = ModuleRevisionId.newInstance("", "", rev1);
             ModuleRevisionId mrid2 = ModuleRevisionId.newInstance("", "", rev2);
-            if (vmatcher.isDynamic(mrid1)) {
+            
+            if (vmatcher.isDynamic(mrid1) && vmatcher.isDynamic(mrid2)) {
+                return vmatcher.compare(mrid1, mrid2, mridComparator);
+            } else if (vmatcher.isDynamic(mrid1)) {
                 int c = vmatcher.compare(mrid1, mrid2, mridComparator);
                 return c >= 0 ? 1 : -1;
             } else if (vmatcher.isDynamic(mrid2)) {

Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/latest/LatestRevisionStrategy.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/latest/LatestRevisionStrategy.java?rev=1376738&r1=1376737&r2=1376738&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/latest/LatestRevisionStrategy.java
(original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/latest/LatestRevisionStrategy.java
Thu Aug 23 22:21:00 2012
@@ -108,7 +108,10 @@ public class LatestRevisionStrategy exte
             VersionMatcher vmatcher = IvyContext.getContext().getSettings().getVersionMatcher();
             ModuleRevisionId mrid1 = ModuleRevisionId.newInstance("", "", rev1);
             ModuleRevisionId mrid2 = ModuleRevisionId.newInstance("", "", rev2);
-            if (vmatcher.isDynamic(mrid1)) {
+
+            if (vmatcher.isDynamic(mrid1) && vmatcher.isDynamic(mrid2)) {
+                return vmatcher.compare(mrid1, mrid2, mridComparator);
+            } else if (vmatcher.isDynamic(mrid1)) {
                 int c = vmatcher.compare(mrid1, mrid2, mridComparator);
                 return c >= 0 ? 1 : -1;
             } else if (vmatcher.isDynamic(mrid2)) {

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=1376738&r1=1376737&r2=1376738&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
Thu Aug 23 22:21:00 2012
@@ -271,6 +271,20 @@ public final class XmlModuleDescriptorUp
             }
 
             flushMergedElementsBefore(qName);
+            
+            // according to ivy.xsd, all <dependency> elements must occur before
+            // the <exclude>, <override> or <conflict> elements
+            if (options.isMerge() 
+                    && ("exclude".equals(localName)
+                            || "override".equals(localName)
+                            || "conflict".equals(localName))
+                    && "ivy-module/dependencies".equals(getContext())) {
+                ModuleDescriptor merged = options.getMergedDescriptor();
+                writeInheritedDependencies(merged);
+                out.println();
+                out.print(getIndent());
+            }
+
             context.push(qName);
 
             String path = getContext();
@@ -360,7 +374,7 @@ public final class XmlModuleDescriptorUp
                         writeInheritedDescription(merged);
                     }
                 }
-
+                
                 // copy
                 write("<" + qName);
                 for (int i = 0; i < attributes.getLength(); i++) {

Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/DependencyResolver.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/DependencyResolver.java?rev=1376738&r1=1376737&r2=1376738&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/DependencyResolver.java (original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/DependencyResolver.java Thu
Aug 23 22:21:00 2012
@@ -55,7 +55,7 @@ public interface DependencyResolver {
     /**
      * Resolve a module by id, getting its module descriptor and resolving the revision if
it's a
      * latest one (i.e. a revision uniquely identifying the revision of a module in the current
-     * environment - If this revision is not able to identify uniquelely the revision of
the module
+     * environment - If this revision is not able to identify uniquely the revision of the
module
      * outside of the current environment, then the resolved revision must begin by ##)
      * 
      * @throws ParseException

Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/version/LatestVersionMatcher.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/version/LatestVersionMatcher.java?rev=1376738&r1=1376737&r2=1376738&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/version/LatestVersionMatcher.java (original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/version/LatestVersionMatcher.java Thu
Aug 23 22:21:00 2012
@@ -57,6 +57,14 @@ public class LatestVersionMatcher extend
      */
     public int compare(ModuleRevisionId askedMrid, ModuleRevisionId foundMrid,
             Comparator staticComparator) {
-        return needModuleDescriptor(askedMrid, foundMrid) ? 0 : 1;
+        if (isDynamic(askedMrid) && !isDynamic(foundMrid)) {
+            return needModuleDescriptor(askedMrid, null) ? 0 : 1;
+        }
+        
+        String askedStatus = askedMrid.getRevision().substring("latest.".length());
+        String foundStatus = foundMrid.getRevision().substring("latest.".length());
+        
+        List statuses = StatusManager.getCurrent().getStatuses();
+        return statuses.indexOf(askedStatus) - statuses.indexOf(foundStatus);
     }
 }

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=1376738&r1=1376737&r2=1376738&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
Thu Aug 23 22:21:00 2012
@@ -46,6 +46,12 @@ import org.apache.ivy.util.FileUtil;
 import org.xml.sax.SAXParseException;
 
 public class XmlModuleUpdaterTest extends TestCase {
+    
+    protected void tearDown() throws Exception {
+        super.tearDown();
+        
+        XmlModuleDescriptorUpdater.LINE_SEPARATOR = System.getProperty("line.separator");
+    }
 
     public void testUpdate() throws Exception {
         /*
@@ -320,6 +326,35 @@ public class XmlModuleUpdaterTest extend
                     .getDependencyArtifacts("myconf2").length);
         }
     }
+    
+    // IVY-1356
+    public void testMergedUpdateWithExtendsAndExcludes() throws Exception {
+        URL url = XmlModuleUpdaterTest.class.getResource("test-extends-dependencies-exclude.xml");
+
+        XmlModuleDescriptorParser parser = XmlModuleDescriptorParser.getInstance();
+        ModuleDescriptor md = parser.parseDescriptor(new IvySettings(), url, true);
+        
+        ByteArrayOutputStream buffer = new ByteArrayOutputStream();
+        XmlModuleDescriptorUpdater.update(url, buffer, 
+            getUpdateOptions("release", "mynewrev")
+                .setMerge(true)
+                .setMergedDescriptor(md));
+        
+        ModuleDescriptor updatedMd = parser.parseDescriptor(new IvySettings(),
+            new ByteArrayInputStream(buffer.toByteArray()), new BasicResource("test", false,
0, 0,
+                    false), true);
+
+        DependencyDescriptor[] deps = updatedMd.getDependencies();
+        assertNotNull("Dependencies shouldn't be null", deps);
+        assertEquals("Number of dependencies is incorrect", 2, deps.length);
+        
+        // test indentation
+        String updatedXml = buffer.toString();
+        System.out.println(updatedXml);
+        assertTrue(updatedXml.indexOf(XmlModuleDescriptorUpdater.LINE_SEPARATOR 
+            + "\t\t<dependency org=\"myorg\" name=\"mymodule1\" rev=\"1.0\" conf=\"default->default\"/>"

+            + XmlModuleDescriptorUpdater.LINE_SEPARATOR) != -1);
+    }
 
     private UpdateOptions getUpdateOptions(String status, String revision) {
         return getUpdateOptions(new IvySettings(), new HashMap(), status, revision, new Date());

Added: ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/parser/xml/test-extends-dependencies-exclude.xml
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/parser/xml/test-extends-dependencies-exclude.xml?rev=1376738&view=auto
==============================================================================
--- ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/parser/xml/test-extends-dependencies-exclude.xml
(added)
+++ ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/parser/xml/test-extends-dependencies-exclude.xml
Thu Aug 23 22:21:00 2012
@@ -0,0 +1,31 @@
+<!--
+   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="1.0">
+	<info organisation="myorg"
+	       module="mymodule"
+	       status="integration"
+	       publication="20091206000000">
+	       <extends organisation="myorg" module="myparent" revision="latest.revision" 
+	       			location="test-extends-parent.xml" extendType="dependencies"/>
+	</info>
+	<dependencies>
+		<dependency name="mymodule2" rev="2.0" conf="default"/>
+		<exclude org="myorg" module="mymodule3"/>
+	</dependencies>
+</ivy-module>



Mime
View raw message