Author: xavier
Date: Fri Feb 1 08:06:57 2008
New Revision: 617535
URL: http://svn.apache.org/viewvc?rev=617535&view=rev
Log:
FIX: IvyDE resolve also evicted artifacts (IVYDE-76) (thanks to Nicolas Lalevée)
Modified:
ant/ivy/ivyde/trunk/CHANGES.txt
ant/ivy/ivyde/trunk/src/java/org/apache/ivyde/eclipse/IvyPlugin.java
ant/ivy/ivyde/trunk/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyClasspathContainer.java
Modified: ant/ivy/ivyde/trunk/CHANGES.txt
URL:
http://svn.apache.org/viewvc/ant/ivy/ivyde/trunk/CHANGES.txt?rev=617535&r1=617534&r2=617535&view=diff
==============================================================================
--- ant/ivy/ivyde/trunk/CHANGES.txt (original)
+++ ant/ivy/ivyde/trunk/CHANGES.txt Fri Feb 1 08:06:57 2008
@@ -11,6 +11,7 @@
- IMPROVE: Support javadoc and sources even in modules where they are not
declared (IVYDE-46)
- IMPROVE: Simplify the resolve process (IVYDE-64) (thanks to Nicolas Lalevée)
+- FIX: IvyDE resolve also evicted artifacts (IVYDE-76) (thanks to Nicolas
Lalevée)
- FIX: IvyDE is using some internal classes of Eclipse (IVYDE-68) (thanks to
Nicolas Lalevée)
- FIX: "Add Ivy library" not working in eclipse 3.3 (IVYDE-57)
- FIX: Automatic javadoc attachment is not working (IVYDE-55)
Modified: ant/ivy/ivyde/trunk/src/java/org/apache/ivyde/eclipse/IvyPlugin.java
URL:
http://svn.apache.org/viewvc/ant/ivy/ivyde/trunk/src/java/org/apache/ivyde/eclipse/IvyPlugin.java?rev=617535&r1=617534&r2=617535&view=diff
==============================================================================
--- ant/ivy/ivyde/trunk/src/java/org/apache/ivyde/eclipse/IvyPlugin.java
(original)
+++ ant/ivy/ivyde/trunk/src/java/org/apache/ivyde/eclipse/IvyPlugin.java Fri
Feb 1 08:06:57 2008
@@ -406,6 +406,15 @@
resolve(project);
}
+ /**
+ * Check if the artifact is an artifact which can be added to the
classpath container
+ *
+ * @param project
+ * the project containing the ivy container
+ * @param artifact
+ * the artifact to check
+ * @return <code>true</code> if the artifact can be added
+ */
public static boolean accept(IJavaProject project, Artifact artifact) {
return getAcceptedTypes(project).contains(artifact.getType())
&& !getSourcesTypes(project).contains(artifact.getType())
Modified:
ant/ivy/ivyde/trunk/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyClasspathContainer.java
URL:
http://svn.apache.org/viewvc/ant/ivy/ivyde/trunk/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyClasspathContainer.java?rev=617535&r1=617534&r2=617535&view=diff
==============================================================================
---
ant/ivy/ivyde/trunk/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyClasspathContainer.java
(original)
+++
ant/ivy/ivyde/trunk/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyClasspathContainer.java
Fri Feb 1 08:06:57 2008
@@ -9,10 +9,12 @@
import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
+import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
+import java.util.Set;
import org.apache.ivy.Ivy;
import org.apache.ivy.core.cache.DefaultRepositoryCacheManager;
@@ -27,6 +29,8 @@
import org.apache.ivy.core.module.descriptor.Artifact;
import org.apache.ivy.core.module.descriptor.DefaultArtifact;
import org.apache.ivy.core.module.descriptor.ModuleDescriptor;
+import org.apache.ivy.core.module.id.ModuleId;
+import org.apache.ivy.core.module.id.ModuleRevisionId;
import org.apache.ivy.core.report.ArtifactDownloadReport;
import org.apache.ivy.core.report.ResolveReport;
import org.apache.ivy.core.resolve.ResolveOptions;
@@ -218,7 +222,7 @@
+ " doesn't contain enough data:
resolving again\n");
ResolveReport r = _ivy.resolve(ivyURL, new
ResolveOptions()
.setConfs(_confs));
-
all.addAll(Arrays.asList(r.getAllArtifactsReports()));
+
all.addAll(Arrays.asList(r.getArtifactsReports(null, false)));
confs = r.getConfigurations();
problemMessages.addAll(r.getAllProblemMessages());
maybeRetrieve(md, confs);
@@ -231,7 +235,8 @@
ResolveReport report = _ivy.resolve(ivyURL, new
ResolveOptions()
.setConfs(_confs));
problemMessages = report.getAllProblemMessages();
- all = new
LinkedHashSet(Arrays.asList(report.getAllArtifactsReports()));
+ all = new
LinkedHashSet(Arrays.asList(report.getArtifactsReports(null,
+ false)));
confs = report.getConfigurations();
md = report.getModuleDescriptor();
@@ -243,6 +248,8 @@
maybeRetrieve(md, confs);
}
+ warnIfDuplicates(all);
+
classpathEntries[0] = artifacts2ClasspathEntries(all);
} catch (ParseException e) {
String errorMsg = "Error while parsing the ivy file "
+ _ivyXmlFile + "\n"
@@ -312,6 +319,53 @@
_job = null;
}
IvyPlugin.log(IStatus.INFO, "resolved dependencies of " +
_ivyXmlFile, null);
+ }
+ }
+
+ /**
+ * Trigger a warn if there are duplicates entries due to configuration
conflict.
+ * <p>
+ * TODO: the algorithm can be more clever and find which configuration
are conflicting.
+ *
+ * @param all
+ * the resolved artifacts
+ */
+ private void warnIfDuplicates(Collection/* <ArtifactDownloadReport>
*/all) {
+ ArtifactDownloadReport[] reports = (ArtifactDownloadReport[]) all
+ .toArray(new ArtifactDownloadReport[all.size()]);
+ Set duplicates = new HashSet();
+ for (int i = 0; i < reports.length - 1; i++) {
+ if (IvyPlugin.accept(_javaProject, reports[i].getArtifact())) {
+ ModuleRevisionId mrid1 =
reports[i].getArtifact().getModuleRevisionId();
+ for (int j = i + 1; j < reports.length; j++) {
+ if (IvyPlugin.accept(_javaProject,
reports[j].getArtifact())) {
+ ModuleRevisionId mrid2 =
reports[j].getArtifact().getModuleRevisionId();
+ if
(mrid1.getModuleId().equals(mrid2.getModuleId()) &&
!mrid1.getRevision().equals(mrid2.getRevision())) {
+ duplicates.add(mrid1.getModuleId());
+ break;
+ }
+ }
+ }
+ }
+ }
+ if (!duplicates.isEmpty()) {
+ StringBuffer buffer = new StringBuffer(
+ "There are some duplicates entries due to conflicts
between the resolved configurations (");
+ for (int i = 0; i < _confs.length; i++) {
+ buffer.append(_confs[i]);
+ if (i < _confs.length - 1) {
+ buffer.append(", ");
+ }
+ }
+ buffer.append("):\n - ");
+ Iterator it = duplicates.iterator();
+ while (it.hasNext()) {
+ buffer.append(it.next());
+ if (it.hasNext()) {
+ buffer.append("\n - ");
+ }
+ }
+ _ivy.getLoggerEngine().log(buffer.toString(),
Message.MSG_WARN);
}
}