Author: cduffy
Date: Fri Dec 27 21:30:33 2013
New Revision: 1553745

URL: http://svn.apache.org/r1553745
Log:
IVY-1455 Prevent incorrect ivy mediators from being applied during conflict 
resolution.

Prior to this, the mediators to be applied depended on the location where a
conflict was detected, rather than the declaration location.

Added:
    ant/ivy/core/trunk/test/repositories/IVY-1455/
    ant/ivy/core/trunk/test/repositories/IVY-1455/ivy.xml
    ant/ivy/core/trunk/test/repositories/IVY-1455/ivysettings.xml
    ant/ivy/core/trunk/test/repositories/IVY-1455/repo/
    ant/ivy/core/trunk/test/repositories/IVY-1455/repo/conflict/
    ant/ivy/core/trunk/test/repositories/IVY-1455/repo/conflict/conflict/
    
ant/ivy/core/trunk/test/repositories/IVY-1455/repo/conflict/conflict/ivy-1.xml
    
ant/ivy/core/trunk/test/repositories/IVY-1455/repo/conflict/conflict/ivy-2.xml
    ant/ivy/core/trunk/test/repositories/IVY-1455/repo/empty-module/
    
ant/ivy/core/trunk/test/repositories/IVY-1455/repo/empty-module/empty-module/
    
ant/ivy/core/trunk/test/repositories/IVY-1455/repo/empty-module/empty-module/ivy-1.xml
    ant/ivy/core/trunk/test/repositories/IVY-1455/repo/reproducer/
    ant/ivy/core/trunk/test/repositories/IVY-1455/repo/reproducer/phase-one/
    
ant/ivy/core/trunk/test/repositories/IVY-1455/repo/reproducer/phase-one/ivy-1.xml
    ant/ivy/core/trunk/test/repositories/IVY-1455/repo/reproducer/phase-two/
    
ant/ivy/core/trunk/test/repositories/IVY-1455/repo/reproducer/phase-two/ivy-1.xml
Modified:
    
ant/ivy/core/trunk/src/java/org/apache/ivy/core/module/descriptor/ModuleDescriptor.java
    
ant/ivy/core/trunk/src/java/org/apache/ivy/core/module/descriptor/OverrideDependencyDescriptorMediator.java
    ant/ivy/core/trunk/src/java/org/apache/ivy/core/resolve/ResolveEngine.java
    ant/ivy/core/trunk/test/java/org/apache/ivy/ant/IvyResolveTest.java

Modified: 
ant/ivy/core/trunk/src/java/org/apache/ivy/core/module/descriptor/ModuleDescriptor.java
URL: 
http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/core/module/descriptor/ModuleDescriptor.java?rev=1553745&r1=1553744&r2=1553745&view=diff
==============================================================================
--- 
ant/ivy/core/trunk/src/java/org/apache/ivy/core/module/descriptor/ModuleDescriptor.java
 (original)
+++ 
ant/ivy/core/trunk/src/java/org/apache/ivy/core/module/descriptor/ModuleDescriptor.java
 Fri Dec 27 21:30:33 2013
@@ -35,7 +35,7 @@ import org.apache.ivy.plugins.version.Ve
 import org.apache.ivy.util.extendable.ExtendableItem;
 
 /**
- * Decriptor of a module. This is the Java representation of an ivy.xml
+ * Descriptor of a module. This is the Java representation of an ivy.xml
  */
 public interface ModuleDescriptor 
         extends ExtendableItem, ArtifactInfo, DependencyDescriptorMediator {

Modified: 
ant/ivy/core/trunk/src/java/org/apache/ivy/core/module/descriptor/OverrideDependencyDescriptorMediator.java
URL: 
http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/core/module/descriptor/OverrideDependencyDescriptorMediator.java?rev=1553745&r1=1553744&r2=1553745&view=diff
==============================================================================
--- 
ant/ivy/core/trunk/src/java/org/apache/ivy/core/module/descriptor/OverrideDependencyDescriptorMediator.java
 (original)
+++ 
ant/ivy/core/trunk/src/java/org/apache/ivy/core/module/descriptor/OverrideDependencyDescriptorMediator.java
 Fri Dec 27 21:30:33 2013
@@ -71,6 +71,12 @@ public class OverrideDependencyDescripto
         
         String version = this.version == null ? mrid.getRevision() : 
this.version;
         String branch = this.branch == null ? mrid.getBranch() : this.branch;
+
+        // if this is a noop, do not construct any new object
+        if(version.equals(dd.getDependencyRevisionId().getRevision())
+            && branch.equals(dd.getDependencyRevisionId().getBranch())) {
+            return dd;
+        }
         
         return dd.clone(ModuleRevisionId.newInstance(
             mrid.getOrganisation(), mrid.getName(), branch, version, 

Modified: 
ant/ivy/core/trunk/src/java/org/apache/ivy/core/resolve/ResolveEngine.java
URL: 
http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/core/resolve/ResolveEngine.java?rev=1553745&r1=1553744&r2=1553745&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/core/resolve/ResolveEngine.java 
(original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/core/resolve/ResolveEngine.java 
Fri Dec 27 21:30:33 2013
@@ -1078,18 +1078,26 @@ public class ResolveEngine {
          */
         if (evictedInSelected || (selectedNodes.isEmpty() 
                         && 
!node.getParent().getNode().equals(ancestor.getNode()))) {
-            // In this case we need to compute selected nodes again. 
-            Collection deps = ancestor.getNode().getDependencies(
-                node.getRootModuleConf(), 
-                
ancestor.getNode().getConfigurations(node.getRootModuleConf()), 
-                ancestor.getRequestedConf());
-            for (Iterator iter = deps.iterator(); iter.hasNext();) {
-                IvyNode dep = (IvyNode) iter.next();
-                if (dep.getModuleId().equals(node.getModuleId())) {
-                    conflicts.add(dep);
+            IvyContext context = IvyContext.getContext();
+            ResolveData data = context.getResolveData();
+            VisitNode oldVisitNode = data.getCurrentVisitNode();
+            data.setCurrentVisitNode(ancestor);
+            try {
+                // In this case we need to compute selected nodes again.
+                Collection deps = ancestor.getNode().getDependencies(
+                    node.getRootModuleConf(), 
+                    
ancestor.getNode().getConfigurations(node.getRootModuleConf()), 
+                    ancestor.getRequestedConf());
+                for (Iterator iter = deps.iterator(); iter.hasNext();) {
+                    IvyNode dep = (IvyNode) iter.next();
+                    if (dep.getModuleId().equals(node.getModuleId())) {
+                        conflicts.add(dep);
+                    }
+                    conflicts.addAll(
+                        dep.getResolvedNodes(node.getModuleId(), 
node.getRootModuleConf()));
                 }
-                conflicts.addAll(
-                    dep.getResolvedNodes(node.getModuleId(), 
node.getRootModuleConf()));
+            } finally {
+                data.setCurrentVisitNode(oldVisitNode);
             }
         } else if (selectedNodes.isEmpty()) {
             /*

Modified: ant/ivy/core/trunk/test/java/org/apache/ivy/ant/IvyResolveTest.java
URL: 
http://svn.apache.org/viewvc/ant/ivy/core/trunk/test/java/org/apache/ivy/ant/IvyResolveTest.java?rev=1553745&r1=1553744&r2=1553745&view=diff
==============================================================================
--- ant/ivy/core/trunk/test/java/org/apache/ivy/ant/IvyResolveTest.java 
(original)
+++ ant/ivy/core/trunk/test/java/org/apache/ivy/ant/IvyResolveTest.java Fri Dec 
27 21:30:33 2013
@@ -64,6 +64,12 @@ public class IvyResolveTest extends Test
         del.execute();
     }
     
+    public void testIVY1455() throws Exception {
+        project.setProperty("ivy.settings.file", 
"test/repositories/IVY-1455/ivysettings.xml");
+        resolve.setFile(new File("test/repositories/IVY-1455/ivy.xml"));
+        resolve.execute();
+    }
+    
     public void testIVY1454() throws Exception {
         // run init in parent thread, then resolve in children
         project.setProperty("ivy.settings.file", 
"test/repositories/ivysettings-with-nio.xml");
@@ -77,9 +83,6 @@ public class IvyResolveTest extends Test
         parallel.addTask(resolve);
         parallel.addTask(resolve);
         parallel.execute();
-        
-        assertTrue(getResolvedIvyFileInCache(
-            ModuleRevisionId.newInstance("apache", "resolve-simple", 
"1.0")).exists());
     }
     
     public void testIVY779() throws Exception {

Added: ant/ivy/core/trunk/test/repositories/IVY-1455/ivy.xml
URL: 
http://svn.apache.org/viewvc/ant/ivy/core/trunk/test/repositories/IVY-1455/ivy.xml?rev=1553745&view=auto
==============================================================================
--- ant/ivy/core/trunk/test/repositories/IVY-1455/ivy.xml (added)
+++ ant/ivy/core/trunk/test/repositories/IVY-1455/ivy.xml Fri Dec 27 21:30:33 
2013
@@ -0,0 +1,39 @@
+<!--
+   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">
+    <info organisation="reproducer" module="top-level" status="integration"/>
+
+    <configurations>
+        <conf name="master"/>
+        <conf name="with-direct-dep" extends="master"/>
+        <!-- without-direct-dep conf not used, but must exist to repro bug -->
+        <conf name="without-direct-dep" extends="master"/>
+    </configurations>
+
+    <publications>
+    </publications>
+
+    <dependencies>
+        <!-- requires conflict==2 [directly] and phase-two (which overrides to 
conflict==1) -->
+        <dependency org="reproducer" name="phase-one" rev="1" 
conf="master->*"/>
+
+        <!-- requires conflict==1 [directly] -->
+        <dependency org="conflict" name="conflict" rev="1" 
conf="with-direct-dep->default"/>
+    </dependencies>
+</ivy-module>

Added: ant/ivy/core/trunk/test/repositories/IVY-1455/ivysettings.xml
URL: 
http://svn.apache.org/viewvc/ant/ivy/core/trunk/test/repositories/IVY-1455/ivysettings.xml?rev=1553745&view=auto
==============================================================================
--- ant/ivy/core/trunk/test/repositories/IVY-1455/ivysettings.xml (added)
+++ ant/ivy/core/trunk/test/repositories/IVY-1455/ivysettings.xml Fri Dec 27 
21:30:33 2013
@@ -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="test"/>
+
+    <resolvers>
+        <filesystem name="test">
+            <ivy 
pattern="${ivy.settings.dir}/repo/[organisation]/[module]/ivy-[revision].xml"/>
+            <artifact 
pattern="${ivy.settings.dir}/repo/[organisation]/[module]/[revision]/[artifact].[ext]"/>
+        </filesystem>
+    </resolvers>
+</ivysettings>

Added: 
ant/ivy/core/trunk/test/repositories/IVY-1455/repo/conflict/conflict/ivy-1.xml
URL: 
http://svn.apache.org/viewvc/ant/ivy/core/trunk/test/repositories/IVY-1455/repo/conflict/conflict/ivy-1.xml?rev=1553745&view=auto
==============================================================================
--- 
ant/ivy/core/trunk/test/repositories/IVY-1455/repo/conflict/conflict/ivy-1.xml 
(added)
+++ 
ant/ivy/core/trunk/test/repositories/IVY-1455/repo/conflict/conflict/ivy-1.xml 
Fri Dec 27 21:30:33 2013
@@ -0,0 +1,23 @@
+<!--
+   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">
+  <info organisation="conflict" module="conflict" revision="1" 
status="release" publication="00000000000000"/>
+  <publications>
+  </publications>
+</ivy-module>

Added: 
ant/ivy/core/trunk/test/repositories/IVY-1455/repo/conflict/conflict/ivy-2.xml
URL: 
http://svn.apache.org/viewvc/ant/ivy/core/trunk/test/repositories/IVY-1455/repo/conflict/conflict/ivy-2.xml?rev=1553745&view=auto
==============================================================================
--- 
ant/ivy/core/trunk/test/repositories/IVY-1455/repo/conflict/conflict/ivy-2.xml 
(added)
+++ 
ant/ivy/core/trunk/test/repositories/IVY-1455/repo/conflict/conflict/ivy-2.xml 
Fri Dec 27 21:30:33 2013
@@ -0,0 +1,23 @@
+<!--
+   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">
+  <info organisation="conflict" module="conflict" revision="2" 
status="release" publication="00000000000000"/>
+  <publications>
+  </publications>
+</ivy-module>

Added: 
ant/ivy/core/trunk/test/repositories/IVY-1455/repo/empty-module/empty-module/ivy-1.xml
URL: 
http://svn.apache.org/viewvc/ant/ivy/core/trunk/test/repositories/IVY-1455/repo/empty-module/empty-module/ivy-1.xml?rev=1553745&view=auto
==============================================================================
--- 
ant/ivy/core/trunk/test/repositories/IVY-1455/repo/empty-module/empty-module/ivy-1.xml
 (added)
+++ 
ant/ivy/core/trunk/test/repositories/IVY-1455/repo/empty-module/empty-module/ivy-1.xml
 Fri Dec 27 21:30:33 2013
@@ -0,0 +1,25 @@
+<!--
+   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">
+  <info organisation="empty-module" module="empty-module" revision="1" 
status="release" publication="00000000000000"/>
+  <publications>
+  </publications>
+  <dependencies>
+  </dependencies>
+</ivy-module>

Added: 
ant/ivy/core/trunk/test/repositories/IVY-1455/repo/reproducer/phase-one/ivy-1.xml
URL: 
http://svn.apache.org/viewvc/ant/ivy/core/trunk/test/repositories/IVY-1455/repo/reproducer/phase-one/ivy-1.xml?rev=1553745&view=auto
==============================================================================
--- 
ant/ivy/core/trunk/test/repositories/IVY-1455/repo/reproducer/phase-one/ivy-1.xml
 (added)
+++ 
ant/ivy/core/trunk/test/repositories/IVY-1455/repo/reproducer/phase-one/ivy-1.xml
 Fri Dec 27 21:30:33 2013
@@ -0,0 +1,26 @@
+<!--
+   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">
+  <info organisation="reproducer" module="phase-one" revision="1" 
status="release" publication="00000000000000"/>
+  <publications/>
+  <dependencies>
+    <dependency org="reproducer" name="phase-two" rev="1"/>
+    <dependency org="conflict" name="conflict" rev="2"/>
+  </dependencies>
+</ivy-module>

Added: 
ant/ivy/core/trunk/test/repositories/IVY-1455/repo/reproducer/phase-two/ivy-1.xml
URL: 
http://svn.apache.org/viewvc/ant/ivy/core/trunk/test/repositories/IVY-1455/repo/reproducer/phase-two/ivy-1.xml?rev=1553745&view=auto
==============================================================================
--- 
ant/ivy/core/trunk/test/repositories/IVY-1455/repo/reproducer/phase-two/ivy-1.xml
 (added)
+++ 
ant/ivy/core/trunk/test/repositories/IVY-1455/repo/reproducer/phase-two/ivy-1.xml
 Fri Dec 27 21:30:33 2013
@@ -0,0 +1,27 @@
+<!--
+   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">
+  <info organisation="reproducer" module="phase-two" revision="1" 
status="release" publication="00000000000000"/>
+  <publications/>
+  <dependencies>
+    <dependency org="empty-module" name="empty-module" rev="1"/>
+    <!-- empty-module doesn't actually include conflict, so in *theory* this 
override would be a noop -->
+    <override org="conflict" module="conflict" matcher="exact" rev="1"/>
+  </dependencies>
+</ivy-module>


Reply via email to