You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ant.apache.org by hi...@apache.org on 2011/04/03 13:33:22 UTC

svn commit: r1088254 - in /ant/ivy/ivyde/trunk: doc/ org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/ org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/handlers...

Author: hibou
Date: Sun Apr  3 11:33:21 2011
New Revision: 1088254

URL: http://svn.apache.org/viewvc?rev=1088254&view=rev
Log:
IVYDE-237:
 - remove the hack with fake java project
 - add in the path of the IvyDE container the project in which it is included so the whole IvyDE container configuration is "stored" there, and thus can be properly used in launch configurations

Added:
    ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/ClasspathEntriesResolver.java   (with props)
Removed:
    ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/FakeProjectManager.java
Modified:
    ant/ivy/ivyde/trunk/doc/release-notes.html
    ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/CachedIvy.java
    ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/IvyDERuntimeClasspathEntryResolver.java
    ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/IvyMarkerManager.java
    ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyClasspathContainerConfAdapter.java
    ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyClasspathContainerConfiguration.java
    ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyClasspathResolver.java
    ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyClasspathUtil.java
    ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvydeContainerPage.java
    ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/handlers/OpenIvyFileHandler.java
    ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/resolve/IvyResolveJob.java
    ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/resolve/IvyResolver.java

Modified: ant/ivy/ivyde/trunk/doc/release-notes.html
URL: http://svn.apache.org/viewvc/ant/ivy/ivyde/trunk/doc/release-notes.html?rev=1088254&r1=1088253&r2=1088254&view=diff
==============================================================================
--- ant/ivy/ivyde/trunk/doc/release-notes.html (original)
+++ ant/ivy/ivyde/trunk/doc/release-notes.html Sun Apr  3 11:33:21 2011
@@ -140,6 +140,7 @@ List of changes since <a href="/ivy/ivyd
     <li>FIX: Variable based path for ivysettings doesn't work it there are some spaces in the path (IVYDE-253)</li>
     <li>FIX: Triggers are not called (IVYDE-244)</li>
     <li>FIX: Missing ivysettings.xml can make the classpath container config to change (IVYDE-248)</li>
+    <li>FIX: Multiple eclipse projects with similar ivy library definitions results in launch config source path collisions (IVYDE-237)</li>
 </ul>
 
 Most of our changes are logged in our JIRA, where you can find comments and links to our subversion:

Modified: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/CachedIvy.java
URL: http://svn.apache.org/viewvc/ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/CachedIvy.java?rev=1088254&r1=1088253&r2=1088254&view=diff
==============================================================================
--- ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/CachedIvy.java (original)
+++ ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/CachedIvy.java Sun Apr  3 11:33:21 2011
@@ -245,9 +245,11 @@ public abstract class CachedIvy {
         } else {
             ivySettings = new IvySettings();
         }
-        IPath location = getProject().getLocation();
-        if (location != null) {
-            ivySettings.setBaseDir(location.toFile());
+        if (getProject() != null) {
+            IPath location = getProject().getLocation();
+            if (location != null) {
+                ivySettings.setBaseDir(location.toFile());
+            }
         }
         Collection propFiles = getPropertyFiles();
         if (propFiles != null) {
@@ -297,7 +299,7 @@ public abstract class CachedIvy {
 
     public File getIvyFile() {
         File file = new File(getIvyXmlPath());
-        if (!file.isAbsolute() && !FakeProjectManager.isFake(getProject())) {
+        if (!file.isAbsolute() && getProject() != null) {
             Path ivyPath = new Path(getIvyXmlPath());
             // get the file location in Eclipse "space"
             IFile ivyfile = getProject().getFile(ivyPath);

Modified: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/IvyDERuntimeClasspathEntryResolver.java
URL: http://svn.apache.org/viewvc/ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/IvyDERuntimeClasspathEntryResolver.java?rev=1088254&r1=1088253&r2=1088254&view=diff
==============================================================================
--- ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/IvyDERuntimeClasspathEntryResolver.java (original)
+++ ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/IvyDERuntimeClasspathEntryResolver.java Sun Apr  3 11:33:21 2011
@@ -20,7 +20,10 @@ package org.apache.ivyde.eclipse;
 import java.util.ArrayList;
 import java.util.List;
 
+import org.apache.ivyde.eclipse.cpcontainer.ClasspathEntriesResolver;
 import org.apache.ivyde.eclipse.cpcontainer.IvyClasspathContainer;
+import org.apache.ivyde.eclipse.resolve.IvyResolveJob;
+import org.apache.ivyde.eclipse.resolve.ResolveRequest;
 import org.eclipse.core.resources.IProject;
 import org.eclipse.core.resources.ResourcesPlugin;
 import org.eclipse.core.runtime.CoreException;
@@ -58,9 +61,7 @@ public class IvyDERuntimeClasspathEntryR
 
         IJavaProject project = entry.getJavaProject();
         if (project == null) {
-            project = JavaRuntime.getJavaProject(configuration);
-            ivycp = new IvyClasspathContainer(FakeProjectManager.createPlaceholderProject(),
-                    entry.getPath(), null, null);
+            ivycp = new IvyClasspathContainer(null, entry.getPath(), null, null);
         } else {
             IClasspathContainer container = JavaCore
                     .getClasspathContainer(entry.getPath(), project);
@@ -74,20 +75,26 @@ public class IvyDERuntimeClasspathEntryR
             ivycp = (IvyClasspathContainer) container;
         }
 
-        return computeDefaultContainerEntries(ivycp, entry, project);
+        return computeDefaultContainerEntries(ivycp, entry);
     }
 
     private static IRuntimeClasspathEntry[] computeDefaultContainerEntries(
-            IvyClasspathContainer ivycp, IRuntimeClasspathEntry entry, IJavaProject project)
-            throws CoreException {
-        if (ivycp.getClasspathEntries() == null
-                || ivycp.getConf().isInheritedResolveBeforeLaunch()) {
-            IStatus status = ivycp.launchResolve(false, new NullProgressMonitor());
+            IvyClasspathContainer ivycp, IRuntimeClasspathEntry entry) throws CoreException {
+        IClasspathEntry[] cpes;
+        if (ivycp.getClasspathEntries() == null || ivycp.getConf().isInheritedResolveBeforeLaunch()) {
+            ClasspathEntriesResolver resolver = new ClasspathEntriesResolver(ivycp, false);
+            ResolveRequest request = new ResolveRequest(resolver, ivycp.getState());
+            request.setForceFailOnError(true);
+            request.setInWorkspace(ivycp.getConf().isInheritedResolveInWorkspace());
+            IvyResolveJob resolveJob = IvyPlugin.getDefault().getIvyResolveJob();
+            IStatus status = resolveJob.launchRequest(request, new NullProgressMonitor());
             if (status.getCode() != IStatus.OK) {
                 throw new CoreException(status);
             }
+            cpes = resolver.getClasspathEntries();
+        } else {
+            cpes = ivycp.getClasspathEntries();
         }
-        IClasspathEntry[] cpes = ivycp.getClasspathEntries();
         List resolved = new ArrayList(cpes.length);
         List projects = new ArrayList();
         for (int i = 0; i < cpes.length; i++) {

Modified: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/IvyMarkerManager.java
URL: http://svn.apache.org/viewvc/ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/IvyMarkerManager.java?rev=1088254&r1=1088253&r2=1088254&view=diff
==============================================================================
--- ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/IvyMarkerManager.java (original)
+++ ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/IvyMarkerManager.java Sun Apr  3 11:33:21 2011
@@ -28,7 +28,7 @@ import org.eclipse.core.runtime.Status;
 public class IvyMarkerManager {
 
     private IResource findResource(IProject project, String ivyXmlFile) {
-        if (FakeProjectManager.isFake(project)) {
+        if (project == null) {
             return null;
         }
         IResource r = project.getFile(ivyXmlFile);

Added: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/ClasspathEntriesResolver.java
URL: http://svn.apache.org/viewvc/ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/ClasspathEntriesResolver.java?rev=1088254&view=auto
==============================================================================
--- ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/ClasspathEntriesResolver.java (added)
+++ ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/ClasspathEntriesResolver.java Sun Apr  3 11:33:21 2011
@@ -0,0 +1,122 @@
+/*
+ *  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.
+ *
+ */
+package org.apache.ivyde.eclipse.cpcontainer;
+
+import java.io.IOException;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Set;
+
+import org.apache.ivy.Ivy;
+import org.apache.ivy.core.module.descriptor.ModuleDescriptor;
+import org.apache.ivy.core.module.id.ModuleRevisionId;
+import org.apache.ivy.core.report.ArtifactDownloadReport;
+import org.apache.ivy.util.Message;
+import org.apache.ivyde.eclipse.resolve.IvyResolver;
+import org.apache.ivyde.eclipse.resolve.ResolveResult;
+import org.apache.ivyde.eclipse.retrieve.RetrieveSetup;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jdt.core.IClasspathEntry;
+
+/**
+ * Eclipse classpath container that will contain the ivy resolved entries.
+ */
+public class ClasspathEntriesResolver extends IvyResolver {
+
+    private final IvyClasspathContainerConfiguration conf;
+
+    private IClasspathEntry[] classpathEntries = null;
+
+    public ClasspathEntriesResolver(IvyClasspathContainer ivycp, boolean usePreviousResolveIfExist) {
+        super(ivycp.getConf().getIvyXmlPath(), ivycp.getConf().getConfs(), ivycp.getConf()
+                .getJavaProject() == null ? null : ivycp.getConf().getJavaProject().getProject());
+        this.conf = ivycp.getConf();
+        setUsePreviousResolveIfExist(ivycp.getConf().isInheritedUseExtendedResolveId());
+        setUsePreviousResolveIfExist(usePreviousResolveIfExist);
+        if (conf.isInheritedRetrievedClasspath()) {
+            RetrieveSetup setup = conf.getInheritedRetrievedClasspathSetup();
+            setRetrievePattern(setup.getRetrievePattern());
+            setRetrieveSync(setup.isRetrieveSync());
+            setRetrieveTypes(setup.getRetrieveTypes());
+        }
+    }
+
+    public IClasspathEntry[] getClasspathEntries() {
+        return classpathEntries;
+    }
+
+    protected void postResolveOrRefresh(Ivy ivy, ModuleDescriptor md, ResolveResult resolveResult,
+            IProgressMonitor monitor) throws IOException {
+        IvyClasspathContainerMapper mapper = new IvyClasspathContainerMapper(monitor, ivy, conf,
+                resolveResult);
+
+        warnIfDuplicates(ivy, mapper, resolveResult.getArtifactReports());
+
+        classpathEntries = mapper.map();
+    }
+
+    /**
+     * 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.
+     * 
+     */
+    private void warnIfDuplicates(Ivy ivy, IvyClasspathContainerMapper mapper, Set artifactReports) {
+        ArtifactDownloadReport[] reports = (ArtifactDownloadReport[]) artifactReports
+                .toArray(new ArtifactDownloadReport[0]);
+
+        Set duplicates = new HashSet();
+
+        for (int i = 0; i < reports.length - 1; i++) {
+            if (!mapper.accept(reports[i].getArtifact())) {
+                continue;
+            }
+
+            ModuleRevisionId mrid1 = reports[i].getArtifact().getModuleRevisionId();
+
+            for (int j = i + 1; j < reports.length; j++) {
+                if (!mapper.accept(reports[j].getArtifact())) {
+                    continue;
+                }
+                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()) {
+            return;
+        }
+
+        StringBuffer buffer = new StringBuffer("There are some duplicates entries due to conflicts"
+                + " between the resolved configurations " + conf.getConfs());
+        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);
+    }
+
+}

Propchange: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/ClasspathEntriesResolver.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/ClasspathEntriesResolver.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision Author HeadURL Id

Propchange: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/ClasspathEntriesResolver.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyClasspathContainerConfAdapter.java
URL: http://svn.apache.org/viewvc/ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyClasspathContainerConfAdapter.java?rev=1088254&r1=1088253&r2=1088254&view=diff
==============================================================================
--- ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyClasspathContainerConfAdapter.java (original)
+++ ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyClasspathContainerConfAdapter.java Sun Apr  3 11:33:21 2011
@@ -24,7 +24,6 @@ import java.net.URLEncoder;
 import java.util.Collections;
 import java.util.List;
 
-import org.apache.ivyde.eclipse.FakeProjectManager;
 import org.apache.ivyde.eclipse.IvyNature;
 import org.apache.ivyde.eclipse.IvyPlugin;
 import org.apache.ivyde.eclipse.retrieve.RetrieveSetup;
@@ -32,10 +31,14 @@ import org.apache.ivyde.eclipse.retrieve
 import org.apache.ivyde.eclipse.retrieve.StandaloneRetrieveSetup;
 import org.apache.ivyde.eclipse.ui.preferences.PreferenceConstants;
 import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IWorkspaceRoot;
+import org.eclipse.core.resources.ResourcesPlugin;
 import org.eclipse.core.runtime.IPath;
 import org.eclipse.core.runtime.IStatus;
 import org.eclipse.core.runtime.Path;
 import org.eclipse.jdt.core.IClasspathAttribute;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.JavaCore;
 import org.eclipse.jface.preference.IPreferenceStore;
 
 /**
@@ -64,7 +67,7 @@ public final class IvyClasspathContainer
         }
         conf.setAttributes(attributes);
 
-        if (!FakeProjectManager.isFake(conf.getJavaProject())) {
+        if (conf.getJavaProject() != null) {
             // ensure that the project has the Ivy nature
             IvyNature.addNature(conf.getJavaProject().getProject());
         }
@@ -122,7 +125,14 @@ public final class IvyClasspathContainer
                 IvyPlugin.log(IStatus.ERROR, UTF8_ERROR, e);
                 throw new RuntimeException(UTF8_ERROR, e);
             }
-            if (parameter[0].equals("ivyXmlPath")) {
+            if (parameter[0].equals("project")) {
+                if (value.trim().length() != 0) {
+                    IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
+                    IProject project = root.getProject(value.trim());
+                    IJavaProject javaProject = JavaCore.create(project);
+                    conf.setProject(javaProject);
+                }
+            } else if (parameter[0].equals("ivyXmlPath")) {
                 ivyXmlPath = value;
                 conf.setIvyXmlPath(value);
             } else if (parameter[0].equals("confs")) {
@@ -291,7 +301,7 @@ public final class IvyClasspathContainer
      * @return
      */
     private static String readOldSettings(IvyClasspathContainerConfiguration conf, String value) {
-        if (FakeProjectManager.isFake(conf.getJavaProject())) {
+        if (conf.getJavaProject() == null) {
             return value;
         }
         if (value.startsWith(PROJECT_SCHEME_PREFIX)) {
@@ -343,8 +353,13 @@ public final class IvyClasspathContainer
     public static IPath getPath(IvyClasspathContainerConfiguration conf) {
         StringBuffer path = new StringBuffer();
         path.append('?');
-        path.append("ivyXmlPath=");
+        IJavaProject javaProject = conf.getJavaProject();
         try {
+            path.append("project=");
+            if (javaProject != null) {
+                path.append(URLEncoder.encode(javaProject.getElementName(), "UTF-8"));
+            }
+            path.append("&ivyXmlPath=");
             path.append(URLEncoder.encode(conf.getIvyXmlPath(), "UTF-8"));
             append(path, "confs", conf.getConfs());
             if (conf.isSettingsProjectSpecific()) {

Modified: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyClasspathContainerConfiguration.java
URL: http://svn.apache.org/viewvc/ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyClasspathContainerConfiguration.java?rev=1088254&r1=1088253&r2=1088254&view=diff
==============================================================================
--- ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyClasspathContainerConfiguration.java (original)
+++ ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyClasspathContainerConfiguration.java Sun Apr  3 11:33:21 2011
@@ -35,7 +35,7 @@ import org.eclipse.jdt.core.IJavaProject
  */
 public class IvyClasspathContainerConfiguration {
 
-    private final IJavaProject javaProject;
+    private IJavaProject javaProject;
 
     private IvySettingsSetup ivySettingsSetup = new IvySettingsSetup();
 
@@ -189,6 +189,10 @@ public class IvyClasspathContainerConfig
         return javaProject;
     }
 
+    public void setProject(IJavaProject javaProject) {
+        this.javaProject = javaProject;
+    }
+
     public void setAttributes(IClasspathAttribute[] attributes) {
         this.attributes = attributes;
     }

Modified: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyClasspathResolver.java
URL: http://svn.apache.org/viewvc/ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyClasspathResolver.java?rev=1088254&r1=1088253&r2=1088254&view=diff
==============================================================================
--- ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyClasspathResolver.java (original)
+++ ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyClasspathResolver.java Sun Apr  3 11:33:21 2011
@@ -17,56 +17,16 @@
  */
 package org.apache.ivyde.eclipse.cpcontainer;
 
-import java.io.IOException;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Set;
-
-import org.apache.ivy.Ivy;
-import org.apache.ivy.core.module.descriptor.ModuleDescriptor;
-import org.apache.ivy.core.module.id.ModuleRevisionId;
-import org.apache.ivy.core.report.ArtifactDownloadReport;
-import org.apache.ivy.util.Message;
-import org.apache.ivyde.eclipse.resolve.IvyResolver;
-import org.apache.ivyde.eclipse.resolve.ResolveResult;
-import org.apache.ivyde.eclipse.retrieve.RetrieveSetup;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.jdt.core.IClasspathEntry;
-
 /**
  * Eclipse classpath container that will contain the ivy resolved entries.
  */
-public class IvyClasspathResolver extends IvyResolver {
-
-    private final IvyClasspathContainerConfiguration conf;
+public class IvyClasspathResolver extends ClasspathEntriesResolver {
 
     private final IvyClasspathContainer ivycp;
 
-    private IClasspathEntry[] classpathEntries = null;
-
     public IvyClasspathResolver(IvyClasspathContainer ivycp, boolean usePreviousResolveIfExist) {
-        super(ivycp.getConf().getIvyXmlPath(), ivycp.getConf().getConfs(), ivycp.getConf()
-                .getJavaProject().getProject());
+        super(ivycp, usePreviousResolveIfExist);
         this.ivycp = ivycp;
-        this.conf = ivycp.getConf();
-        setUsePreviousResolveIfExist(ivycp.getConf().isInheritedUseExtendedResolveId());
-        setUsePreviousResolveIfExist(usePreviousResolveIfExist);
-        if (conf.isInheritedRetrievedClasspath()) {
-            RetrieveSetup setup = conf.getInheritedRetrievedClasspathSetup();
-            setRetrievePattern(setup.getRetrievePattern());
-            setRetrieveSync(setup.isRetrieveSync());
-            setRetrieveTypes(setup.getRetrieveTypes());
-        }
-    }
-
-    protected void postResolveOrRefresh(Ivy ivy, ModuleDescriptor md, ResolveResult resolveResult,
-            IProgressMonitor monitor) throws IOException {
-        IvyClasspathContainerMapper mapper = new IvyClasspathContainerMapper(monitor, ivy, conf,
-                resolveResult);
-
-        warnIfDuplicates(ivy, mapper, resolveResult.getArtifactReports());
-
-        classpathEntries = mapper.map();
     }
 
     /*
@@ -75,59 +35,9 @@ public class IvyClasspathResolver extend
      * doing anything.
      */
     public void postBatchResolve() {
-        if (classpathEntries != null) {
-            ivycp.updateClasspathEntries(classpathEntries);
-        }
-    }
-
-    /**
-     * 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.
-     * 
-     */
-    private void warnIfDuplicates(Ivy ivy, IvyClasspathContainerMapper mapper,
-            Set artifactReports) {
-        ArtifactDownloadReport[] reports = (ArtifactDownloadReport[]) artifactReports
-                .toArray(new ArtifactDownloadReport[0]);
-
-        Set duplicates = new HashSet();
-
-        for (int i = 0; i < reports.length - 1; i++) {
-            if (!mapper.accept(reports[i].getArtifact())) {
-                continue;
-            }
-
-            ModuleRevisionId mrid1 = reports[i].getArtifact().getModuleRevisionId();
-
-            for (int j = i + 1; j < reports.length; j++) {
-                if (!mapper.accept(reports[j].getArtifact())) {
-                    continue;
-                }
-                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()) {
-            return;
-        }
-
-        StringBuffer buffer = new StringBuffer("There are some duplicates entries due to conflicts"
-                + " between the resolved configurations " + conf.getConfs());
-        buffer.append(":\n  - ");
-        Iterator it = duplicates.iterator();
-        while (it.hasNext()) {
-            buffer.append(it.next());
-            if (it.hasNext()) {
-                buffer.append("\n  - ");
-            }
+        if (getClasspathEntries() != null) {
+            ivycp.updateClasspathEntries(getClasspathEntries());
         }
-        ivy.getLoggerEngine().log(buffer.toString(), Message.MSG_WARN);
     }
 
 }

Modified: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyClasspathUtil.java
URL: http://svn.apache.org/viewvc/ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyClasspathUtil.java?rev=1088254&r1=1088253&r2=1088254&view=diff
==============================================================================
--- ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyClasspathUtil.java (original)
+++ ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyClasspathUtil.java Sun Apr  3 11:33:21 2011
@@ -30,7 +30,6 @@ import java.util.List;
 import org.apache.ivy.core.module.descriptor.ModuleDescriptor;
 import org.apache.ivy.core.module.id.ModuleRevisionId;
 import org.apache.ivy.core.resolve.ResolveOptions;
-import org.apache.ivyde.eclipse.FakeProjectManager;
 import org.apache.ivyde.eclipse.IvyDEException;
 import org.apache.ivyde.eclipse.IvyPlugin;
 import org.eclipse.core.resources.IFile;
@@ -117,7 +116,7 @@ public final class IvyClasspathUtil {
     public static List/* <IvyClasspathContainer> */getIvyClasspathContainers(
             IJavaProject javaProject) {
         List/* <IvyClasspathContainer> */containers = new ArrayList();
-        if (FakeProjectManager.isFake(javaProject) || !javaProject.exists()) {
+        if (javaProject == null || !javaProject.exists()) {
             return containers;
         }
         try {
@@ -144,7 +143,7 @@ public final class IvyClasspathUtil {
     public static List/* <IvyClasspathContainer> */getIvyFileClasspathContainers(IFile ivyfile) {
         IJavaProject javaProject = JavaCore.create(ivyfile.getProject());
         List/* <IvyClasspathContainer> */containers = new ArrayList();
-        if (FakeProjectManager.isFake(javaProject) || !javaProject.exists()) {
+        if (javaProject == null || !javaProject.exists()) {
             return containers;
         }
         try {
@@ -176,7 +175,7 @@ public final class IvyClasspathUtil {
             IFile ivySettings) {
         IJavaProject javaProject = JavaCore.create(ivySettings.getProject());
         List/* <IvyClasspathContainer> */containers = new ArrayList();
-        if (FakeProjectManager.isFake(javaProject) || !javaProject.exists()) {
+        if (javaProject == null || !javaProject.exists()) {
             return containers;
         }
         try {
@@ -282,7 +281,7 @@ public final class IvyClasspathUtil {
      */
     public static IClasspathEntry getIvyClasspathEntry(IPath containerPath,
             IJavaProject javaProject) {
-        if (FakeProjectManager.isFake(javaProject) || !javaProject.exists()) {
+        if (javaProject == null || !javaProject.exists()) {
             return null;
         }
         try {

Modified: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvydeContainerPage.java
URL: http://svn.apache.org/viewvc/ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvydeContainerPage.java?rev=1088254&r1=1088253&r2=1088254&view=diff
==============================================================================
--- ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvydeContainerPage.java (original)
+++ ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvydeContainerPage.java Sun Apr  3 11:33:21 2011
@@ -23,7 +23,6 @@ import java.util.Iterator;
 import java.util.List;
 
 import org.apache.ivy.core.module.descriptor.ModuleDescriptor;
-import org.apache.ivyde.eclipse.FakeProjectManager;
 import org.apache.ivyde.eclipse.IvyDEException;
 import org.apache.ivyde.eclipse.IvyMarkerManager;
 import org.apache.ivyde.eclipse.IvyPlugin;
@@ -83,7 +82,7 @@ public class IvydeContainerPage extends 
     private Button resolveInWorkspaceCheck;
 
     private Button resolveBeforeLaunchCheck;
-    
+
     private Button useExtendedResolveIdCheck;
 
     private Button advancedProjectSpecificButton;
@@ -117,6 +116,10 @@ public class IvydeContainerPage extends 
         super("IvyDE Container");
     }
 
+    public IJavaProject getProject() {
+        return project;
+    }
+
     void checkCompleted() {
         String error = null;
         if (ivyFilePathText.getIvyFilePath().length() == 0) {
@@ -225,17 +228,20 @@ public class IvydeContainerPage extends 
 
         entry = JavaCore.newContainerEntry(path, null, atts, exported);
 
-        try {
-            IvyClasspathContainer ivycp = new IvyClasspathContainer(project, path,
-                    new IClasspathEntry[0], atts);
-            JavaCore.setClasspathContainer(path, new IJavaProject[] {project},
-                new IClasspathContainer[] {ivycp}, null);
-            ivycp.launchResolve(false, null);
-        } catch (JavaModelException e) {
-            IvyPlugin.log(e);
+        if (project != null) {
+            try {
+                IvyClasspathContainer ivycp = new IvyClasspathContainer(project, path,
+                        new IClasspathEntry[0], atts);
+                JavaCore.setClasspathContainer(path, new IJavaProject[] {project},
+                    new IClasspathContainer[] {ivycp}, null);
+                ivycp.launchResolve(false, null);
+            } catch (JavaModelException e) {
+                IvyPlugin.log(e);
+            }
         }
 
-        if (oldIvyFile != null && !oldIvyFile.equals(conf.getIvyXmlPath())) {
+        if (conf.getJavaProject() != null && oldIvyFile != null
+                && !oldIvyFile.equals(conf.getIvyXmlPath())) {
             // changing the ivy.xml, remove old marker on the old file, if any
             IvyMarkerManager ivyMarkerManager = IvyPlugin.getDefault().getIvyMarkerManager();
             ivyMarkerManager.removeMarkers(conf.getJavaProject().getProject(), oldIvyFile);
@@ -244,16 +250,11 @@ public class IvydeContainerPage extends 
         return true;
     }
 
-    public IJavaProject getProject() {
-        return project;
-    }
-
     public IClasspathEntry getSelection() {
         return entry;
     }
 
     public void setSelection(IClasspathEntry entry) {
-        checkProject();
         if (entry == null) {
             conf = new IvyClasspathContainerConfiguration(project, "ivy.xml", true);
         } else {
@@ -267,12 +268,11 @@ public class IvydeContainerPage extends 
     }
 
     public void setSelection(IFile ivyfile) {
-        checkProject();
         conf = new IvyClasspathContainerConfiguration(project, ivyfile.getProjectRelativePath()
                 .toString(), true);
         // if there is an ivysettings.xml file at the root of the project, configure the container
         // to use it
-        if (!FakeProjectManager.isFake(project)) {
+        if (project != null) {
             IResource settings = project.getProject().findMember(new Path("ivysettings.xml"));
             if (settings != null) {
                 conf.setSettingsProjectSpecific(true);
@@ -285,12 +285,6 @@ public class IvydeContainerPage extends 
         state = new IvyClasspathContainerState(conf);
     }
 
-    private void checkProject() {
-        if (project == null) {
-            project = FakeProjectManager.createPlaceholderProject();
-        }
-    }
-
     public void createControl(Composite parent) {
         setTitle("IvyDE Managed Libraries");
         setDescription("Choose ivy file and its configurations.");
@@ -349,7 +343,8 @@ public class IvydeContainerPage extends 
         Label pathLabel = new Label(configComposite, SWT.NONE);
         pathLabel.setText("Ivy File");
 
-        ivyFilePathText = new IvyFilePathText(configComposite, SWT.NONE, project.getProject());
+        ivyFilePathText = new IvyFilePathText(configComposite, SWT.NONE, project == null ? null
+                : project.getProject());
         ivyFilePathText.addListener(new IvyXmlPathListener() {
             public void ivyXmlPathUpdated(String path) {
                 conf.setIvyXmlPath(path);
@@ -499,7 +494,7 @@ public class IvydeContainerPage extends 
                 helper.getRetrievedClasspathSetup());
         }
 
-        if (FakeProjectManager.isFake(project)) {
+        if (project == null) {
             // container in a launch config: always resolve before launch
             resolveBeforeLaunchCheck.setEnabled(false);
             resolveBeforeLaunchCheck.setSelection(true);
@@ -517,7 +512,7 @@ public class IvydeContainerPage extends 
         alphaOrderCheck.setEnabled(projectSpecific);
         resolveInWorkspaceCheck.setEnabled(projectSpecific);
         useExtendedResolveIdCheck.setEnabled(projectSpecific);
-        resolveBeforeLaunchCheck.setEnabled(projectSpecific && !FakeProjectManager.isFake(project));
+        resolveBeforeLaunchCheck.setEnabled(projectSpecific && project != null);
         classpathTypeComposite.setEnabled(projectSpecific);
     }
 

Modified: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/handlers/OpenIvyFileHandler.java
URL: http://svn.apache.org/viewvc/ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/handlers/OpenIvyFileHandler.java?rev=1088254&r1=1088253&r2=1088254&view=diff
==============================================================================
--- ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/handlers/OpenIvyFileHandler.java (original)
+++ ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/handlers/OpenIvyFileHandler.java Sun Apr  3 11:33:21 2011
@@ -17,7 +17,6 @@
  */
 package org.apache.ivyde.eclipse.handlers;
 
-import org.apache.ivyde.eclipse.FakeProjectManager;
 import org.apache.ivyde.eclipse.cpcontainer.IvyClasspathContainer;
 import org.apache.ivyde.eclipse.cpcontainer.IvyClasspathContainerConfiguration;
 import org.eclipse.core.resources.IFile;
@@ -43,7 +42,7 @@ public class OpenIvyFileHandler extends 
 
     public static void open(IvyClasspathContainer cp) {
         IvyClasspathContainerConfiguration conf = cp.getConf();
-        if (FakeProjectManager.isFake(conf.getJavaProject())) {
+        if (conf.getJavaProject() == null) {
             return;
         }
         IFile file = conf.getJavaProject().getProject().getFile(conf.getIvyXmlPath());

Modified: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/resolve/IvyResolveJob.java
URL: http://svn.apache.org/viewvc/ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/resolve/IvyResolveJob.java?rev=1088254&r1=1088253&r2=1088254&view=diff
==============================================================================
--- ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/resolve/IvyResolveJob.java (original)
+++ ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/resolve/IvyResolveJob.java Sun Apr  3 11:33:21 2011
@@ -32,11 +32,9 @@ import org.apache.ivy.plugins.circular.C
 import org.apache.ivy.plugins.circular.WarnCircularDependencyStrategy;
 import org.apache.ivy.plugins.version.VersionMatcher;
 import org.apache.ivyde.eclipse.CachedIvy;
-import org.apache.ivyde.eclipse.FakeProjectManager;
 import org.apache.ivyde.eclipse.IvyDEException;
 import org.apache.ivyde.eclipse.IvyMarkerManager;
 import org.apache.ivyde.eclipse.IvyPlugin;
-import org.apache.ivyde.eclipse.ui.preferences.IvyPreferencePage;
 import org.eclipse.core.resources.IProject;
 import org.eclipse.core.resources.ResourcesPlugin;
 import org.eclipse.core.runtime.IProgressMonitor;
@@ -100,6 +98,8 @@ public class IvyResolveJob extends Job {
 
         int step = IVY_LOAD_LENGTH / toResolve.size();
 
+        boolean forceFailOnError = false;
+
         // Ivy use the SaxParserFactory, and we want it to instanciate the xerces parser which is in
         // the dependencies of IvyDE, so accessible via the current classloader
         ClassLoader old = Thread.currentThread().getContextClassLoader();
@@ -108,9 +108,10 @@ public class IvyResolveJob extends Job {
             Iterator itRequests = toResolve.iterator();
             while (itRequests.hasNext()) {
                 ResolveRequest request = (ResolveRequest) itRequests.next();
+                forceFailOnError = forceFailOnError || request.isForceFailOnError();
                 monitor.subTask("loading " + request.getResolver().toString());
                 IProject project = request.getResolver().getProject();
-                if (!FakeProjectManager.isFake(project) && !project.isAccessible()) {
+                if (project != null && !project.isAccessible()) {
                     // closed project, skip it
                     monitor.worked(step);
                     continue;
@@ -201,6 +202,14 @@ public class IvyResolveJob extends Job {
             }
         }
 
+        if (errorsStatus.getChildren().length != 0) {
+            // some errors happend, stop here
+            if (forceFailOnError || IvyPlugin.getPreferenceStoreHelper().isErrorPopup()) {
+                return errorsStatus;
+            }
+            return Status.OK_STATUS;
+        }
+
         step = POST_RESOLVE_LENGTH / toResolve.size();
 
         monitor.setTaskName("Post resolve");
@@ -214,11 +223,6 @@ public class IvyResolveJob extends Job {
             monitor.worked(step);
         }
 
-        if (IvyPlugin.getPreferenceStoreHelper().isErrorPopup()
-                && errorsStatus.getChildren().length != 0) {
-            return errorsStatus;
-        }
-
         return Status.OK_STATUS;
     }
 

Modified: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/resolve/IvyResolver.java
URL: http://svn.apache.org/viewvc/ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/resolve/IvyResolver.java?rev=1088254&r1=1088253&r2=1088254&view=diff
==============================================================================
--- ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/resolve/IvyResolver.java (original)
+++ ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/resolve/IvyResolver.java Sun Apr  3 11:33:21 2011
@@ -42,7 +42,6 @@ import org.apache.ivy.plugins.report.Xml
 import org.apache.ivy.plugins.resolver.DependencyResolver;
 import org.apache.ivy.util.Message;
 import org.apache.ivy.util.filter.ArtifactTypeFilter;
-import org.apache.ivyde.eclipse.FakeProjectManager;
 import org.apache.ivyde.eclipse.IvyPlugin;
 import org.apache.ivyde.eclipse.cpcontainer.IvyClasspathUtil;
 import org.eclipse.core.resources.IFolder;
@@ -276,7 +275,7 @@ public class IvyResolver {
 
     private void maybeRetrieve(Ivy ivy, ModuleDescriptor md, ResolveResult result,
             IProgressMonitor monitor) throws IOException {
-        if (retrievePattern == null || FakeProjectManager.isFake(project)) {
+        if (retrievePattern == null || project == null) {
             return;
         }
 
@@ -330,6 +329,6 @@ public class IvyResolver {
     }
 
     public String toString() {
-        return ivyXmlPath + confInput + " in " + project.getName();
+        return ivyXmlPath + confInput + (project == null ? "" : (" in " + project.getName()));
     }
 }