You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ant.apache.org by xa...@apache.org on 2008/03/10 22:10:50 UTC

svn commit: r635695 - in /ant/ivy/core/trunk: CHANGES.txt src/java/org/apache/ivy/core/retrieve/RetrieveEngine.java test/java/org/apache/ivy/core/retrieve/RetrieveTest.java

Author: xavier
Date: Mon Mar 10 14:10:48 2008
New Revision: 635695

URL: http://svn.apache.org/viewvc?rev=635695&view=rev
Log:
FIX: Ivy reports a conflict when the same file is supposed to be retrieved at the same location twice (or more) (IVY-743)

Modified:
    ant/ivy/core/trunk/CHANGES.txt
    ant/ivy/core/trunk/src/java/org/apache/ivy/core/retrieve/RetrieveEngine.java
    ant/ivy/core/trunk/test/java/org/apache/ivy/core/retrieve/RetrieveTest.java

Modified: ant/ivy/core/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/CHANGES.txt?rev=635695&r1=635694&r2=635695&view=diff
==============================================================================
--- ant/ivy/core/trunk/CHANGES.txt (original)
+++ ant/ivy/core/trunk/CHANGES.txt Mon Mar 10 14:10:48 2008
@@ -70,6 +70,7 @@
 - IMPROVEMENT: Make Ivy standalone runnable with no required dependencies (IVY-757)
 - IMPROVEMENT: add branch attribute in ivy:install task (IVY-727)
 
+- FIX: Ivy reports a conflict when the same file is supposed to be retrieved at the same location twice (or more) (IVY-743)
 - FIX: StackOverflowError when configuration extends itself (IVY-696)
 - FIX: XML schema ambiguity (IVY-750)
 - FIX: ivy-resolve fails when a project has different dependencies in different branches (IVY-717)

Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/core/retrieve/RetrieveEngine.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/core/retrieve/RetrieveEngine.java?rev=635695&r1=635694&r2=635695&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/core/retrieve/RetrieveEngine.java (original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/core/retrieve/RetrieveEngine.java Mon Mar 10 14:10:48 2008
@@ -257,8 +257,10 @@
 
         // ArtifactDownloadReport source -> Set (String copyDestAbsolutePath)
         final Map artifactsToCopy = new HashMap();
-        // String copyDestAbsolutePath -> Set (ArtifactDownloadReport source)
+        // String copyDestAbsolutePath -> Set (ArtifactRevisionId source)
         final Map conflictsMap = new HashMap(); 
+        // String copyDestAbsolutePath -> Set (ArtifactDownloadReport source)
+        final Map conflictsReportsMap = new HashMap(); 
         // String copyDestAbsolutePath -> Set (String conf)
         final Map conflictsConfMap = new HashMap(); 
         
@@ -299,17 +301,24 @@
                 dest.add(copyDest);
 
                 Set conflicts = (Set) conflictsMap.get(copyDest);
+                Set conflictsReports = (Set) conflictsReportsMap.get(copyDest);
                 Set conflictsConf = (Set) conflictsConfMap.get(copyDest);
                 if (conflicts == null) {
                     conflicts = new HashSet();
                     conflictsMap.put(copyDest, conflicts);
                 }
+                if (conflictsReports == null) {
+                    conflictsReports = new HashSet();
+                    conflictsReportsMap.put(copyDest, conflictsReports);
+                }
                 if (conflictsConf == null) {
                     conflictsConf = new HashSet();
                     conflictsConfMap.put(copyDest, conflictsConf);
                 }
-                conflicts.add(artifact);
-                conflictsConf.add(conf);
+                if (conflicts.add(artifact.getArtifact().getId())) {
+                    conflictsReports.add(artifact);
+                    conflictsConf.add(conf);
+                }
             }
         }
 
@@ -319,7 +328,7 @@
             Set artifacts = (Set) conflictsMap.get(copyDest);
             Set conflictsConfs = (Set) conflictsConfMap.get(copyDest);
             if (artifacts.size() > 1) {
-                List artifactsList = new ArrayList(artifacts);
+                List artifactsList = new ArrayList((Collection) conflictsReportsMap.get(copyDest));
                 // conflicts battle is resolved by a sort using a conflict resolving policy
                 // comparator
                 // which consider as greater a winning artifact

Modified: ant/ivy/core/trunk/test/java/org/apache/ivy/core/retrieve/RetrieveTest.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/test/java/org/apache/ivy/core/retrieve/RetrieveTest.java?rev=635695&r1=635694&r2=635695&view=diff
==============================================================================
--- ant/ivy/core/trunk/test/java/org/apache/ivy/core/retrieve/RetrieveTest.java (original)
+++ ant/ivy/core/trunk/test/java/org/apache/ivy/core/retrieve/RetrieveTest.java Mon Mar 10 14:10:48 2008
@@ -33,6 +33,8 @@
 import org.apache.ivy.core.module.descriptor.ModuleDescriptor;
 import org.apache.ivy.core.report.ResolveReport;
 import org.apache.ivy.core.resolve.ResolveOptions;
+import org.apache.ivy.util.Message;
+import org.apache.ivy.util.MockMessageLogger;
 import org.apache.tools.ant.Project;
 import org.apache.tools.ant.taskdefs.Delete;
 
@@ -85,6 +87,24 @@
         ivy.retrieve(md.getModuleRevisionId(), pattern, getRetrieveOptions());
         assertTrue(new File(IvyPatternHelper.substitute(pattern, "org1", "mod1.2", "2.0", "mod1.2",
             "jar", "jar", "default")).exists());
+    }
+
+    public void testRetrieveSameFileConflict() throws Exception {
+        // mod1.1 depends on mod1.2
+        ResolveReport report = ivy.resolve(new File(
+                "test/repositories/1/org1/mod1.4/ivys/ivy-1.0.1.xml").toURL(),
+            getResolveOptions(new String[] {"*"}));
+        assertNotNull(report);
+        ModuleDescriptor md = report.getModuleDescriptor();
+        assertNotNull(md);
+
+        String pattern = "build/test/retrieve/[module]/[artifact]-[revision].[ext]";
+        MockMessageLogger mockLogger = new MockMessageLogger();
+        Message.setDefaultLogger(mockLogger);
+        ivy.retrieve(md.getModuleRevisionId(), pattern, getRetrieveOptions());
+        assertTrue(new File(IvyPatternHelper.substitute(pattern, "org1", "mod1.2", "2.2", "mod1.2",
+            "jar", "jar", "default")).exists());
+        mockLogger.assertLogDoesntContain("conflict on");
     }
 
     public void testEvent() throws Exception {