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 2009/03/17 00:27:04 UTC
svn commit: r755043 - 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: maartenc
Date: Mon Mar 16 23:27:03 2009
New Revision: 755043
URL: http://svn.apache.org/viewvc?rev=755043&view=rev
Log:
IMPROVEMENT: Fail the retrieve when multiple artifacts of same module are mapped to same file (IVY-1050)
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=755043&r1=755042&r2=755043&view=diff
==============================================================================
--- ant/ivy/core/trunk/CHANGES.txt (original)
+++ ant/ivy/core/trunk/CHANGES.txt Mon Mar 16 23:27:03 2009
@@ -86,6 +86,7 @@
trunk
=====================================
+- IMPROVEMENT: Fail the retrieve when multiple artifacts of same module are mapped to same file (IVY-1050)
- IMPROVEMENT: ivy initialization shouldn't fail if properties file doesn't exist (IVY-1038)
- IMPROVEMENT: ivy:resolve ant task does not support "branch" attribute (IVY-1035)
- IMPROVEMENT: Ability to strip revConstraint attribute from delivered Ivy files (IVY-989)
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=755043&r1=755042&r2=755043&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 16 23:27:03 2009
@@ -326,7 +326,7 @@
}
}
}
-
+
// resolve conflicts if any
for (Iterator iter = conflictsMap.keySet().iterator(); iter.hasNext();) {
String copyDest = (String) iter.next();
@@ -335,17 +335,29 @@
if (artifacts.size() > 1) {
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
+ // comparator which consider as greater a winning artifact
Collections.sort(artifactsList, getConflictResolvingPolicy());
+
// after the sort, the winning artifact is the greatest one, i.e. the last one
+ // we fail if different artifacts of the same module are mapped to the same file
+ ArtifactDownloadReport winner = (ArtifactDownloadReport)
+ artifactsList.get(artifactsList.size() - 1);
+ ModuleRevisionId winnerMD = winner.getArtifact().getModuleRevisionId();
+ for (int i = artifactsList.size() - 2; i >= 0; i--) {
+ ArtifactDownloadReport current = (ArtifactDownloadReport) artifactsList.get(i);
+ if (winnerMD.equals(current.getArtifact().getModuleRevisionId())) {
+ throw new RuntimeException("Multiple artifacts of the module " + winnerMD +
+ " are retrieved to the same file! Update the retrieve pattern " +
+ " to fix this error.");
+ }
+ }
+
Message.info("\tconflict on "
+ copyDest
+ " in "
+ conflictsConfs
+ ": "
- + ((ArtifactDownloadReport) artifactsList.get(artifactsList.size() - 1))
- .getArtifact().getModuleRevisionId().getRevision() + " won");
+ + winnerMD.getRevision() + " won");
// we now iterate over the list beginning with the artifact preceding the winner,
// and going backward to the least 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=755043&r1=755042&r2=755043&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 16 23:27:03 2009
@@ -107,6 +107,26 @@
mockLogger.assertLogDoesntContain("conflict on");
}
+ public void testRetrieveDifferentArtifactsOfSameModuleToSameFile() throws Exception {
+ ResolveReport report = ivy.resolve(new File(
+ "test/repositories/1/org2/mod2.2/ivys/ivy-0.5.xml").toURL(),
+ getResolveOptions(new String[] {"*"}));
+ assertNotNull(report);
+ ModuleDescriptor md = report.getModuleDescriptor();
+ assertNotNull(md);
+
+ String pattern = "build/test/retrieve/[module]/[module].[ext]";
+ MockMessageLogger mockLogger = new MockMessageLogger();
+ Message.setDefaultLogger(mockLogger);
+ try {
+ ivy.retrieve(md.getModuleRevisionId(), pattern, getRetrieveOptions());
+ fail("Exeption should have been thrown!");
+ } catch (RuntimeException e) {
+ // expected!
+ }
+ mockLogger.assertLogDoesntContain("multiple artifacts");
+ }
+
public void testEvent() throws Exception {
ResolveReport report = ivy.resolve(new File(
"test/repositories/1/org1/mod1.1/ivys/ivy-1.0.xml").toURL(),