You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ant.apache.org by ma...@apache.org on 2011/01/05 23:55:07 UTC

svn commit: r1055675 - in /ant/ivy/core/trunk: ./ src/java/org/apache/ivy/core/resolve/ test/java/org/apache/ivy/core/resolve/ test/repositories/IVY-1236/ test/repositories/IVY-1236/myorg/ test/repositories/IVY-1236/myorg/modA/ test/repositories/IVY-12...

Author: maartenc
Date: Wed Jan  5 22:55:07 2011
New Revision: 1055675

URL: http://svn.apache.org/viewvc?rev=1055675&view=rev
Log:
FIX: Dynamic version resolution result can be incorrect when ivy metadata contains extra attributes (IVY-1236)

Added:
    ant/ivy/core/trunk/test/repositories/IVY-1236/
    ant/ivy/core/trunk/test/repositories/IVY-1236/ivy.xml
    ant/ivy/core/trunk/test/repositories/IVY-1236/ivysettings.xml
    ant/ivy/core/trunk/test/repositories/IVY-1236/myorg/
    ant/ivy/core/trunk/test/repositories/IVY-1236/myorg/modA/
    ant/ivy/core/trunk/test/repositories/IVY-1236/myorg/modA/1.0/
    ant/ivy/core/trunk/test/repositories/IVY-1236/myorg/modA/1.0/ivy.xml
    ant/ivy/core/trunk/test/repositories/IVY-1236/myorg/modB/
    ant/ivy/core/trunk/test/repositories/IVY-1236/myorg/modB/1.0/
    ant/ivy/core/trunk/test/repositories/IVY-1236/myorg/modB/1.0/ivy.xml
    ant/ivy/core/trunk/test/repositories/IVY-1236/myorg/modB/1.0/modB-A.jar
    ant/ivy/core/trunk/test/repositories/IVY-1236/myorg/modB/1.0/modB.jar
Modified:
    ant/ivy/core/trunk/CHANGES.txt
    ant/ivy/core/trunk/src/java/org/apache/ivy/core/resolve/IvyNodeEviction.java
    ant/ivy/core/trunk/test/java/org/apache/ivy/core/resolve/ResolveTest.java

Modified: ant/ivy/core/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/CHANGES.txt?rev=1055675&r1=1055674&r2=1055675&view=diff
==============================================================================
--- ant/ivy/core/trunk/CHANGES.txt (original)
+++ ant/ivy/core/trunk/CHANGES.txt Wed Jan  5 22:55:07 2011
@@ -117,6 +117,7 @@ for detailed view of each issue, please 
 - NEW: ivy:resolve and post resole task can now have inlined dependencies declaration.
 - NEW: Import Bushel into Ivy core (IVY-1241)
 
+- FIX: Dynamic version resolution result can be incorrect when ivy metadata contains extra attributes (IVY-1236)
 - FIX: NullPointerException in FileUtil#forceDelete.
 - FIX: XmlModuleDescriptorUpdater is a mess that produces broken xmls in many cases (IVY-1010)
 - FIX: ivy.xml that contains UTF-8 encoded umlauts cannot be bigger than 10000 bytes (IVY-1253)

Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/core/resolve/IvyNodeEviction.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/core/resolve/IvyNodeEviction.java?rev=1055675&r1=1055674&r2=1055675&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/core/resolve/IvyNodeEviction.java (original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/core/resolve/IvyNodeEviction.java Wed Jan  5 22:55:07 2011
@@ -25,6 +25,7 @@ import java.util.Map;
 import java.util.Set;
 
 import org.apache.ivy.core.module.id.ModuleId;
+import org.apache.ivy.core.module.id.ModuleRevisionId;
 import org.apache.ivy.plugins.conflict.ConflictManager;
 
 public class IvyNodeEviction {
@@ -227,8 +228,16 @@ public class IvyNodeEviction {
             Collection resolvedRevs = new HashSet();
             for (Iterator iter = resolved.iterator(); iter.hasNext();) {
                 IvyNode node = (IvyNode) iter.next();
+                ModuleRevisionId resolvedId = node.getResolvedId();
                 resolvedRevs.add(node.getId());
-                resolvedRevs.add(node.getResolvedId());
+                resolvedRevs.add(resolvedId);
+                
+                // in case there are extra attributes on the resolved module we also add the 
+                // the module without these extra attributes (cfr. IVY-1236)
+                if (!resolvedId.getExtraAttributes().isEmpty()) {
+                    resolvedRevs.add(ModuleRevisionId.newInstance(resolvedId.getOrganisation(), 
+                        resolvedId.getName(), resolvedId.getBranch(), resolvedId.getRevision()));
+                }
             }
             return resolvedRevs;
         }
@@ -274,14 +283,18 @@ public class IvyNodeEviction {
 
     public boolean isEvicted(String rootModuleConf) {
         cleanEvicted();
+        if (node.isRoot()) {
+            return false;
+        }
+        EvictionData evictedData = getEvictedData(rootModuleConf);
+        if (evictedData == null) {
+            return false;
+        }
         IvyNode root = node.getRoot();
         ModuleId moduleId = node.getId().getModuleId();
         Collection resolvedRevisions = root.getResolvedRevisions(moduleId, rootModuleConf);
-        EvictionData evictedData = getEvictedData(rootModuleConf);
-        return root != node && evictedData != null 
-            && (!resolvedRevisions.contains(node.getResolvedId())
-                || evictedData.isTransitivelyEvicted()
-               );
+        return !resolvedRevisions.contains(node.getResolvedId())
+                       || evictedData.isTransitivelyEvicted();
     }
 
     public boolean isCompletelyEvicted() {

Modified: ant/ivy/core/trunk/test/java/org/apache/ivy/core/resolve/ResolveTest.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/test/java/org/apache/ivy/core/resolve/ResolveTest.java?rev=1055675&r1=1055674&r2=1055675&view=diff
==============================================================================
--- ant/ivy/core/trunk/test/java/org/apache/ivy/core/resolve/ResolveTest.java (original)
+++ ant/ivy/core/trunk/test/java/org/apache/ivy/core/resolve/ResolveTest.java Wed Jan  5 22:55:07 2011
@@ -3347,6 +3347,24 @@ public class ResolveTest extends TestCas
         assertFalse(getArchiveFileInCache("myorg", "modE", "1.1", "modE", "jar", "jar").exists());
     }
 
+    public void testIVY1236() throws Exception {
+        Ivy ivy = new Ivy();
+        ivy.configure(new File("test/repositories/IVY-1236/ivysettings.xml"));
+        ResolveReport report = ivy.resolve(new File("test/repositories/IVY-1236/ivy.xml").toURI().toURL(),
+            getResolveOptions(new String[] {"*"}));
+        
+        assertNotNull(report);
+        assertNotNull(report.getUnresolvedDependencies());
+        assertEquals("Number of unresolved dependencies not correct", 0, report
+                .getUnresolvedDependencies().length);
+        
+        // dependencies
+        assertTrue(getIvyFileInCache(
+            ModuleRevisionId.newInstance("myorg", "modB", "1.0")).exists());
+        assertTrue(getArchiveFileInCache("myorg", "modB", "1.0", "modB", "jar", "jar").exists());
+        assertTrue(getArchiveFileInCache("myorg", "modB", "1.0", "modB-A", "jar", "jar").exists());
+    }
+
     public void testIVY999() throws Exception {
         Ivy ivy = new Ivy();
         ivy.configure(new File("test/repositories/IVY-999/ivysettings.xml"));

Added: ant/ivy/core/trunk/test/repositories/IVY-1236/ivy.xml
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/test/repositories/IVY-1236/ivy.xml?rev=1055675&view=auto
==============================================================================
--- ant/ivy/core/trunk/test/repositories/IVY-1236/ivy.xml (added)
+++ ant/ivy/core/trunk/test/repositories/IVY-1236/ivy.xml Wed Jan  5 22:55:07 2011
@@ -0,0 +1,29 @@
+<!--
+   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="test" />
+    <configurations>
+        <conf name="runtime" />
+        <conf name="test" extends="runtime" />
+    </configurations>
+    <dependencies>
+        <dependency org="myorg" name="modB" rev="[1.0,2.0[" conf="runtime" />
+        <dependency org="myorg" name="modA" rev="[1.0,2.0[" conf="test->runtime" />
+    </dependencies>
+</ivy-module>

Added: ant/ivy/core/trunk/test/repositories/IVY-1236/ivysettings.xml
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/test/repositories/IVY-1236/ivysettings.xml?rev=1055675&view=auto
==============================================================================
--- ant/ivy/core/trunk/test/repositories/IVY-1236/ivysettings.xml (added)
+++ ant/ivy/core/trunk/test/repositories/IVY-1236/ivysettings.xml Wed Jan  5 22:55:07 2011
@@ -0,0 +1,28 @@
+<!--
+   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.
+-->
+<ivysettings>
+   <settings defaultResolver="local" />
+   <resolvers>
+        <filesystem name="local" >
+            <ivy pattern="${ivy.settings.dir}/[organisation]/[module]/[revision]/ivy.xml"/>
+            <artifact pattern="${ivy.settings.dir}/[organisation]/[module]/[revision]/[artifact].[ext]"/>
+        </filesystem>
+    </resolvers>
+    
+</ivysettings>

Added: ant/ivy/core/trunk/test/repositories/IVY-1236/myorg/modA/1.0/ivy.xml
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/test/repositories/IVY-1236/myorg/modA/1.0/ivy.xml?rev=1055675&view=auto
==============================================================================
--- ant/ivy/core/trunk/test/repositories/IVY-1236/myorg/modA/1.0/ivy.xml (added)
+++ ant/ivy/core/trunk/test/repositories/IVY-1236/myorg/modA/1.0/ivy.xml Wed Jan  5 22:55:07 2011
@@ -0,0 +1,28 @@
+<!--
+   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="modA" revision="1.0" />
+    <configurations>
+        <conf name="runtime" />
+    </configurations>
+    <publications />
+    <dependencies>
+        <dependency org="myorg" name="modB" rev="1.0" conf="runtime->all"/>
+	</dependencies>
+</ivy-module>

Added: ant/ivy/core/trunk/test/repositories/IVY-1236/myorg/modB/1.0/ivy.xml
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/test/repositories/IVY-1236/myorg/modB/1.0/ivy.xml?rev=1055675&view=auto
==============================================================================
--- ant/ivy/core/trunk/test/repositories/IVY-1236/myorg/modB/1.0/ivy.xml (added)
+++ ant/ivy/core/trunk/test/repositories/IVY-1236/myorg/modB/1.0/ivy.xml Wed Jan  5 22:55:07 2011
@@ -0,0 +1,32 @@
+<!--
+   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.2" xmlns:extra="http://ant.apache.org/ivy/extra">
+    <info organisation="myorg" module="modB" revision="1.0" extra:foo="bar"/>
+    <configurations>
+        <conf name="runtime" visibility="public" />
+        <conf name="conf1" extends="runtime" />
+        <conf name="conf2" extends="runtime" />
+        <conf name="all" extends="conf1,conf2" visibility="public" />
+    </configurations>
+    <publications>
+        <artifact name="modB" type="jar" ext="jar" conf="runtime"/>
+        <artifact name="modB-A" type="jar" ext="jar" conf="conf1"/>
+    </publications>
+    <dependencies />
+</ivy-module>

Added: ant/ivy/core/trunk/test/repositories/IVY-1236/myorg/modB/1.0/modB-A.jar
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/test/repositories/IVY-1236/myorg/modB/1.0/modB-A.jar?rev=1055675&view=auto
==============================================================================
--- ant/ivy/core/trunk/test/repositories/IVY-1236/myorg/modB/1.0/modB-A.jar (added)
+++ ant/ivy/core/trunk/test/repositories/IVY-1236/myorg/modB/1.0/modB-A.jar Wed Jan  5 22:55:07 2011
@@ -0,0 +1 @@
+.
\ No newline at end of file

Added: ant/ivy/core/trunk/test/repositories/IVY-1236/myorg/modB/1.0/modB.jar
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/test/repositories/IVY-1236/myorg/modB/1.0/modB.jar?rev=1055675&view=auto
==============================================================================
--- ant/ivy/core/trunk/test/repositories/IVY-1236/myorg/modB/1.0/modB.jar (added)
+++ ant/ivy/core/trunk/test/repositories/IVY-1236/myorg/modB/1.0/modB.jar Wed Jan  5 22:55:07 2011
@@ -0,0 +1 @@
+.
\ No newline at end of file