ant-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hi...@apache.org
Subject svn commit: r991977 - in /ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse: cpcontainer/ handlers/ resolve/ ui/menu/ workspaceresolver/
Date Thu, 02 Sep 2010 15:20:29 GMT
Author: hibou
Date: Thu Sep  2 15:20:22 2010
New Revision: 991977

URL: http://svn.apache.org/viewvc?rev=991977&view=rev
Log:
Continuing some refactoring about the IvyDE resolve API. Now the standalone retrieve is part
of the resolve job whith all scheduling and error reporting.

Modified:
    ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyClasspathContainer.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/IvyResolveJob.java
    ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/ResolveRequest.java
    ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/handlers/RefreshHandler.java
    ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/handlers/ResolveAllHandler.java
    ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/handlers/ResolveHandler.java
    ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/resolve/IvyResolver.java
    ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/menu/RetrieveAction.java
    ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/workspaceresolver/WorkspaceResourceChangeListener.java

Modified: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyClasspathContainer.java
URL: http://svn.apache.org/viewvc/ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyClasspathContainer.java?rev=991977&r1=991976&r2=991977&view=diff
==============================================================================
--- ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyClasspathContainer.java
(original)
+++ ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyClasspathContainer.java
Thu Sep  2 15:20:22 2010
@@ -25,7 +25,6 @@ import java.util.Comparator;
 import org.apache.ivy.Ivy;
 import org.apache.ivy.core.module.descriptor.ModuleDescriptor;
 import org.apache.ivy.core.resolve.ResolveOptions;
-import org.apache.ivyde.eclipse.IvyDEException;
 import org.apache.ivyde.eclipse.IvyPlugin;
 import org.eclipse.core.runtime.IPath;
 import org.eclipse.core.runtime.IProgressMonitor;
@@ -127,7 +126,9 @@ public class IvyClasspathContainer imple
     }
 
     public IStatus launchResolve(boolean usePreviousResolveIfExist, IProgressMonitor monitor)
{
-        ResolveRequest request = new ResolveRequest(this, usePreviousResolveIfExist);
+        ResolveRequest request = new ResolveRequest(new IvyClasspathResolver(this,
+                usePreviousResolveIfExist), getState());
+        request.setInWorkspace(getConf().isInheritedResolveInWorkspace());
         IvyResolveJob resolveJob = IvyPlugin.getDefault().getIvyResolveJob();
         if (monitor != null) {
             return resolveJob.launchRequest(request, monitor);
@@ -152,8 +153,8 @@ public class IvyClasspathContainer imple
                 if (conf.isInheritedAlphaOrder()) {
                     Arrays.sort(entries, new Comparator() {
                         public int compare(Object o1, Object o2) {
-                            return ((IClasspathEntry) o1).getPath().lastSegment().compareTo(
-                                ((IClasspathEntry) o2).getPath().lastSegment());
+                            return ((IClasspathEntry) o1).getPath().lastSegment()
+                                    .compareTo(((IClasspathEntry) o2).getPath().lastSegment());
                         }
                     });
                 }
@@ -227,8 +228,10 @@ public class IvyClasspathContainer imple
         }
         String resolveId = ResolveOptions.getDefaultResolveId(md);
         try {
-            return ivy.getResolutionCacheManager().getConfigurationResolveReportInCache(resolveId,
-                md.getConfigurationsNames()[0]).toURL();
+            return ivy
+                    .getResolutionCacheManager()
+                    .getConfigurationResolveReportInCache(resolveId, md.getConfigurationsNames()[0])
+                    .toURL();
         } catch (MalformedURLException e) {
             // should never happen
             throw new RuntimeException(e);
@@ -237,7 +240,7 @@ public class IvyClasspathContainer imple
 
     public void reloadSettings() {
         state.setIvySettingsLastModified(-1);
-        launchResolve(false,  null);
+        launchResolve(false, null);
     }
 
     public String toString() {

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=991977&r1=991976&r2=991977&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
Thu Sep  2 15:20:22 2010
@@ -39,30 +39,29 @@ public class IvyClasspathResolver extend
 
     private final IvyClasspathContainerConfiguration conf;
 
-    private IClasspathEntry[] classpathEntries = null;
+    private final IvyClasspathContainer ivycp;
 
-    public IvyClasspathResolver(IvyClasspathContainerConfiguration conf, Ivy ivy,
-            ModuleDescriptor md, boolean usePreviousResolveIfExist, IProgressMonitor monitor)
{
-        super(ivy, conf.getIvyXmlPath(), md, monitor, conf.getConfs(), conf.getJavaProject()
-                .getProject());
+    public IvyClasspathResolver(IvyClasspathContainer ivycp, boolean usePreviousResolveIfExist)
{
+        super(ivycp.getConf().getIvyXmlPath(), ivycp.getConf().getConfs(), ivycp.getConf()
+                .getJavaProject().getProject());
+        this.ivycp = ivycp;
+        this.conf = ivycp.getConf();
         setUsePreviousResolveIfExist(usePreviousResolveIfExist);
         setRetrievePattern(conf.getRetrievedClasspathSetup().getRetrievePattern());
         setRetrieveSync(conf.getRetrievedClasspathSetup().isRetrieveSync());
         setRetrieveTypes(conf.getRetrievedClasspathSetup().getRetrieveTypes());
-        this.conf = conf;
     }
 
-    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);
 
-    protected void postResolveOrRefresh(ResolveResult resolveResult) throws IOException {
-        IvyClasspathContainerMapper mapper = new IvyClasspathContainerMapper(getMonitor(),
-                getIvy(), conf, resolveResult);
+        warnIfDuplicates(ivy, mapper, resolveResult.getArtifactReports());
 
-        warnIfDuplicates(mapper, resolveResult.getArtifactReports());
+        IClasspathEntry[] classpathEntries = mapper.map();
 
-        classpathEntries = mapper.map();
+        ivycp.updateClasspathEntries(classpathEntries);
     }
 
     /**
@@ -71,7 +70,7 @@ public class IvyClasspathResolver extend
      * TODO: the algorithm can be more clever and find which configuration are conflicting.
      * 
      */
-    private void warnIfDuplicates(IvyClasspathContainerMapper mapper, Set artifactReports)
{
+    private void warnIfDuplicates(Ivy ivy, IvyClasspathContainerMapper mapper, Set artifactReports)
{
         ArtifactDownloadReport[] reports = (ArtifactDownloadReport[]) artifactReports
                 .toArray(new ArtifactDownloadReport[0]);
 
@@ -111,7 +110,7 @@ public class IvyClasspathResolver extend
                 buffer.append("\n  - ");
             }
         }
-        getIvy().getLoggerEngine().log(buffer.toString(), Message.MSG_WARN);
+        ivy.getLoggerEngine().log(buffer.toString(), Message.MSG_WARN);
     }
 
 }

Modified: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyResolveJob.java
URL: http://svn.apache.org/viewvc/ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyResolveJob.java?rev=991977&r1=991976&r2=991977&view=diff
==============================================================================
--- ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyResolveJob.java
(original)
+++ ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyResolveJob.java
Thu Sep  2 15:20:22 2010
@@ -31,9 +31,11 @@ import org.apache.ivy.core.sort.WarningN
 import org.apache.ivy.plugins.circular.CircularDependencyStrategy;
 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.IvyDEException;
 import org.apache.ivyde.eclipse.IvyMarkerManager;
 import org.apache.ivyde.eclipse.IvyPlugin;
+import org.apache.ivyde.eclipse.resolve.IvyResolver;
 import org.apache.ivyde.eclipse.resolve.IvyRunner;
 import org.eclipse.core.resources.ResourcesPlugin;
 import org.eclipse.core.runtime.IProgressMonitor;
@@ -93,35 +95,35 @@ public class IvyResolveJob extends Job {
             Iterator itRequests = toResolve.iterator();
             while (itRequests.hasNext()) {
                 ResolveRequest request = (ResolveRequest) itRequests.next();
-                IvyClasspathContainerState state = request.getContainer().getState();
+                CachedIvy cachedIvy = request.getCachedIvy();
                 Ivy ivy;
                 try {
-                    ivy = state.getIvy();
+                    ivy = cachedIvy.getIvy();
                 } catch (IvyDEException e) {
-                    state.setErrorMarker(e);
+                    cachedIvy.setErrorMarker(e);
                     errorsStatus.add(e.asStatus(IStatus.ERROR, "Failed to configure Ivy for
"
                             + request));
                     continue;
                 }
-                state.setErrorMarker(null);
+                cachedIvy.setErrorMarker(null);
                 ivys.put(request, ivy);
                 // IVYDE-168 : Ivy needs the IvyContext in the threadlocal in order to found
the
                 // default branch
                 ivy.pushContext();
                 ModuleDescriptor md;
                 try {
-                    md = state.getModuleDescriptor(ivy);
+                    md = cachedIvy.getModuleDescriptor(ivy);
                 } catch (IvyDEException e) {
-                    state.setErrorMarker(e);
+                    cachedIvy.setErrorMarker(e);
                     errorsStatus.add(e.asStatus(IStatus.ERROR, "Failed to load the descriptor
for "
                             + request));
                     continue;
                 } finally {
                     ivy.popContext();
                 }
-                state.setErrorMarker(null);
+                cachedIvy.setErrorMarker(null);
                 mds.put(request, md);
-                if (request.getContainer().getConf().isInheritedResolveInWorkspace()) {
+                if (request.isInWorkspace()) {
                     inworkspaceModules.put(md, request);
                 } else {
                     otherModules.add(request);
@@ -179,18 +181,15 @@ public class IvyResolveJob extends Job {
         return Status.OK_STATUS;
     }
 
-    private boolean launchResolveThread(ResolveRequest request, IProgressMonitor monitor,
-            MultiStatus errorsStatus, Ivy ivy, ModuleDescriptor md) {
-
-        IvyClasspathContainerConfiguration conf = request.getContainer().getConf();
-        final IvyClasspathResolver resolver = new IvyClasspathResolver(conf, ivy, md,
-                request.isUsePreviousResolveIfExist(), monitor);
+    private boolean launchResolveThread(ResolveRequest request, final IProgressMonitor monitor,
+            MultiStatus errorsStatus, final Ivy ivy, final ModuleDescriptor md) {
 
         final IStatus[] status = new IStatus[1];
 
+        final IvyResolver resolver = request.getResolver();
         Runnable resolveRunner = new Runnable() {
             public void run() {
-                status[0] = resolver.resolve();
+                status[0] = resolver.resolve(ivy, md, monitor);
             }
         };
 
@@ -199,13 +198,9 @@ public class IvyResolveJob extends Job {
             return true;
         }
 
-        if (status[0] == Status.OK_STATUS) {
-            request.getContainer().updateClasspathEntries(resolver.getClasspathEntries());
-        }
-
         IvyMarkerManager ivyMarkerManager = IvyPlugin.getDefault().getIvyMarkerManager();
-        ivyMarkerManager.setResolveStatus(status[0], conf.getJavaProject().getProject(),
-            conf.getIvyXmlPath());
+        ivyMarkerManager.setResolveStatus(status[0], resolver.getProject(),
+            resolver.getIvyXmlPath());
 
         switch (status[0].getCode()) {
             case IStatus.CANCEL:

Modified: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/ResolveRequest.java
URL: http://svn.apache.org/viewvc/ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/ResolveRequest.java?rev=991977&r1=991976&r2=991977&view=diff
==============================================================================
--- ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/ResolveRequest.java
(original)
+++ ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/ResolveRequest.java
Thu Sep  2 15:20:22 2010
@@ -17,26 +17,36 @@
  */
 package org.apache.ivyde.eclipse.cpcontainer;
 
+import org.apache.ivyde.eclipse.CachedIvy;
+import org.apache.ivyde.eclipse.resolve.IvyResolver;
+
 public class ResolveRequest {
 
-    private final IvyClasspathContainer ivycp;
+    private final IvyResolver resolver;
+
+    private final CachedIvy cachedIvy;
+
+    private boolean inWorkspace = false;
 
-    private final boolean usePreviousResolveIfExist;
+    public ResolveRequest(IvyResolver resolver, CachedIvy cachedIvy) {
+        this.resolver = resolver;
+        this.cachedIvy = cachedIvy;
+    }
 
-    public ResolveRequest(IvyClasspathContainer ivycp, boolean usePreviousResolveIfExist)
{
-        this.ivycp = ivycp;
-        this.usePreviousResolveIfExist = usePreviousResolveIfExist;
+    public IvyResolver getResolver() {
+        return resolver;
     }
 
-    public IvyClasspathContainer getContainer() {
-        return ivycp;
+    public CachedIvy getCachedIvy() {
+        return cachedIvy;
     }
 
-    public boolean isUsePreviousResolveIfExist() {
-        return usePreviousResolveIfExist;
+    public void setInWorkspace(boolean inWorkspace) {
+        this.inWorkspace  = inWorkspace;
     }
-    
-    public String toString() {
-        return ivycp.toString();
+
+    public boolean isInWorkspace() {
+        return inWorkspace;
     }
+
 }

Modified: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/handlers/RefreshHandler.java
URL: http://svn.apache.org/viewvc/ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/handlers/RefreshHandler.java?rev=991977&r1=991976&r2=991977&view=diff
==============================================================================
--- ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/handlers/RefreshHandler.java
(original)
+++ ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/handlers/RefreshHandler.java
Thu Sep  2 15:20:22 2010
@@ -17,25 +17,15 @@
  */
 package org.apache.ivyde.eclipse.handlers;
 
-import org.apache.ivyde.eclipse.IvyPlugin;
 import org.apache.ivyde.eclipse.cpcontainer.IvyClasspathContainer;
-import org.apache.ivyde.eclipse.cpcontainer.IvyResolveJob;
-import org.apache.ivyde.eclipse.cpcontainer.ResolveRequest;
 import org.eclipse.core.resources.IProject;
 
 public class RefreshHandler extends AbstractIvyDEHandler {
 
     public static final String COMMAND_ID = "org.apache.ivyde.commands.refresh";
 
-    private IvyResolveJob resolveJob;
-
-    public RefreshHandler() {
-        resolveJob = IvyPlugin.getDefault().getIvyResolveJob();
-    }
-
     protected void handleContainer(IProject project, IvyClasspathContainer ivycp) {
-        ResolveRequest request = new ResolveRequest(ivycp, true);
-        resolveJob.addRequest(request);
+        ivycp.launchResolve(true, null);
     }
 
 }

Modified: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/handlers/ResolveAllHandler.java
URL: http://svn.apache.org/viewvc/ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/handlers/ResolveAllHandler.java?rev=991977&r1=991976&r2=991977&view=diff
==============================================================================
--- ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/handlers/ResolveAllHandler.java
(original)
+++ ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/handlers/ResolveAllHandler.java
Thu Sep  2 15:20:22 2010
@@ -19,11 +19,8 @@ package org.apache.ivyde.eclipse.handler
 
 import java.util.Iterator;
 
-import org.apache.ivyde.eclipse.IvyPlugin;
 import org.apache.ivyde.eclipse.cpcontainer.IvyClasspathContainer;
 import org.apache.ivyde.eclipse.cpcontainer.IvyClasspathUtil;
-import org.apache.ivyde.eclipse.cpcontainer.IvyResolveJob;
-import org.apache.ivyde.eclipse.cpcontainer.ResolveRequest;
 import org.eclipse.core.commands.AbstractHandler;
 import org.eclipse.core.commands.ExecutionEvent;
 import org.eclipse.core.commands.ExecutionException;
@@ -45,13 +42,11 @@ public class ResolveAllHandler extends A
             return null;
         }
 
-        IvyResolveJob resolveJob = IvyPlugin.getDefault().getIvyResolveJob();
         for (int i = 0; i < projects.length; i++) {
             Iterator it = IvyClasspathUtil.getIvyClasspathContainers(projects[i]).iterator();
             while (it.hasNext()) {
                 IvyClasspathContainer ivycp = (IvyClasspathContainer) it.next();
-                ResolveRequest request = new ResolveRequest(ivycp, false);
-                resolveJob.addRequest(request);
+                ivycp.launchResolve(false, null);
             }
         }
 

Modified: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/handlers/ResolveHandler.java
URL: http://svn.apache.org/viewvc/ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/handlers/ResolveHandler.java?rev=991977&r1=991976&r2=991977&view=diff
==============================================================================
--- ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/handlers/ResolveHandler.java
(original)
+++ ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/handlers/ResolveHandler.java
Thu Sep  2 15:20:22 2010
@@ -17,25 +17,15 @@
  */
 package org.apache.ivyde.eclipse.handlers;
 
-import org.apache.ivyde.eclipse.IvyPlugin;
 import org.apache.ivyde.eclipse.cpcontainer.IvyClasspathContainer;
-import org.apache.ivyde.eclipse.cpcontainer.IvyResolveJob;
-import org.apache.ivyde.eclipse.cpcontainer.ResolveRequest;
 import org.eclipse.core.resources.IProject;
 
 public class ResolveHandler extends AbstractIvyDEHandler {
 
     public static final String COMMAND_ID = "org.apache.ivyde.commands.resolve";
 
-    private IvyResolveJob resolveJob;
-
-    public ResolveHandler() {
-        resolveJob = IvyPlugin.getDefault().getIvyResolveJob();
-    }
-
     protected void handleContainer(IProject project, IvyClasspathContainer ivycp) {
-        ResolveRequest request = new ResolveRequest(ivycp, false);
-        resolveJob.addRequest(request);
+        ivycp.launchResolve(false, null);
     }
 
 }

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=991977&r1=991976&r2=991977&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
Thu Sep  2 15:20:22 2010
@@ -61,12 +61,6 @@ public class IvyResolver {
 
     private static final int MONITOR_LENGTH = 1000;
 
-    private final Ivy ivy;
-
-    private final IProgressMonitor monitor;
-
-    private final ModuleDescriptor md;
-
     private boolean usePreviousResolveIfExist = false;
 
     private String[] confs;
@@ -83,15 +77,10 @@ public class IvyResolver {
 
     private final String ivyXmlPath;
 
-    public IvyResolver(Ivy ivy, String ivyXmlPath, ModuleDescriptor md, IProgressMonitor
monitor, List confInput,
-            IProject project) {
+    public IvyResolver(String ivyXmlPath, List confInput, IProject project) {
         this.ivyXmlPath = ivyXmlPath;
         this.confInput = confInput;
         this.project = project;
-        this.ivy = ivy;
-        this.md = md;
-        this.monitor = monitor;
-        computeConfs(confInput);
     }
 
     public void setUsePreviousResolveIfExist(boolean usePreviousResolveIfExist) {
@@ -110,27 +99,16 @@ public class IvyResolver {
         this.retrieveTypes = retrieveTypes;
     }
 
-    public Ivy getIvy() {
-        return ivy;
-    }
-
-    public IProgressMonitor getMonitor() {
-        return monitor;
-    }
-
-    public ModuleDescriptor getMd() {
-        return md;
-    }
-
-    public String[] getConfs() {
-        return confs;
+    public String getIvyXmlPath() {
+        return ivyXmlPath;
     }
 
     public IProject getProject() {
         return project;
     }
 
-    public IStatus resolve() {
+    public IStatus resolve(Ivy ivy, ModuleDescriptor md, IProgressMonitor monitor) {
+        computeConfs(confInput, md);
         try {
             ivy.pushContext();
             IvyResolveJobListener ivyResolveJobListener = new IvyResolveJobListener(monitor);
@@ -147,14 +125,14 @@ public class IvyResolver {
             Thread.currentThread().setContextClassLoader(IvyResolver.class.getClassLoader());
             try {
                 if (usePreviousResolveIfExist) {
-                    result = resolveWithPrevious();
+                    result = resolveWithPrevious(ivy, md);
                 } else {
-                    result = doResolve();
+                    result = doResolve(ivy, md);
                 }
 
-                maybeRetrieve(result);
+                maybeRetrieve(ivy, md, result, monitor);
 
-                postResolveOrRefresh(result);
+                postResolveOrRefresh(ivy, md, result, monitor);
             } catch (ParseException e) {
                 String errorMsg = "Error while parsing the ivy file from " + this.toString()
+ "\n"
                         + e.getMessage();
@@ -188,11 +166,12 @@ public class IvyResolver {
         }
     }
 
-    protected void postResolveOrRefresh(ResolveResult resolveResult) throws IOException {
+    protected void postResolveOrRefresh(Ivy ivy, ModuleDescriptor md, ResolveResult resolveResult,
+            IProgressMonitor monitor) throws IOException {
         // nothing to do by default
     }
 
-    private void computeConfs(List/* <String> */confInput) {
+    private void computeConfs(List/* <String> */confInput, ModuleDescriptor md) {
         Set configurations = new HashSet();
         configurations.addAll(confInput);
 
@@ -203,7 +182,8 @@ public class IvyResolver {
         }
     }
 
-    private ResolveResult resolveWithPrevious() throws ParseException, IOException {
+    private ResolveResult resolveWithPrevious(Ivy ivy, ModuleDescriptor md) throws ParseException,
+            IOException {
         ResolveResult result = new ResolveResult();
 
         // we check if all required configurations have been resolved
@@ -216,12 +196,12 @@ public class IvyResolver {
                     XmlReportParser parser = new XmlReportParser();
                     parser.parse(report);
                     result.addArtifactReports(parser.getArtifactReports());
-                    findAllArtifactOnRefresh(parser, result);
+                    findAllArtifactOnRefresh(ivy, parser, result);
                 } catch (ParseException e) {
                     Message.info("\n\nIVYDE: Error while parsing the report " + report
                             + ". Falling back by doing a resolve again.");
                     // it fails, so let's try resolving for all configuration
-                    return doResolve();
+                    return doResolve(ivy, md);
                 }
             }
         }
@@ -229,7 +209,8 @@ public class IvyResolver {
         return result;
     }
 
-    private ResolveResult doResolve() throws ParseException, IOException {
+    private ResolveResult doResolve(Ivy ivy, ModuleDescriptor md) throws ParseException,
+            IOException {
         ResolveOptions resolveOption = new ResolveOptions().setConfs(confs);
         resolveOption.setValidate(ivy.getSettings().doValidate());
         ResolveReport report = ivy.resolve(md, resolveOption);
@@ -259,7 +240,7 @@ public class IvyResolver {
      * @param parser
      * @throws ParseException
      */
-    private void findAllArtifactOnRefresh(XmlReportParser parser, ResolveResult result)
+    private void findAllArtifactOnRefresh(Ivy ivy, XmlReportParser parser, ResolveResult
result)
             throws ParseException {
         ModuleRevisionId[] dependencyMrdis = parser.getDependencyRevisionIds();
         for (int iDep = 0; iDep < dependencyMrdis.length; iDep++) {
@@ -288,18 +269,19 @@ public class IvyResolver {
         }
     }
 
-    private void maybeRetrieve(ResolveResult result) throws IOException {
+    private void maybeRetrieve(Ivy ivy, ModuleDescriptor md, ResolveResult result,
+            IProgressMonitor monitor) throws IOException {
         if (result.isPreviousUsed() || retrievePattern == null
                 || FakeProjectManager.isFake(project)) {
             return;
         }
 
         String pattern = project.getLocation().toPortableString() + "/" + retrievePattern;
-        getMonitor().setTaskName("retrieving dependencies in " + pattern);
+        monitor.setTaskName("retrieving dependencies in " + pattern);
         RetrieveOptions options = new RetrieveOptions();
         options.setSync(retrieveSync);
         options.setResolveId(result.getReport().getResolveId());
-        options.setConfs(getConfs());
+        options.setConfs(confs);
         if (retrieveTypes != null && !retrieveTypes.equals("*")) {
             options.setArtifactFilter(new ArtifactTypeFilter(IvyClasspathUtil.split(retrieveTypes)));
         }
@@ -307,8 +289,7 @@ public class IvyResolver {
         // Actually do the retrieve
         // FIXME here we will parse a report we already have
         // with a better Java API, we could do probably better
-        int numberOfItemsRetrieved = getIvy().retrieve(getMd().getModuleRevisionId(), pattern,
-            options);
+        int numberOfItemsRetrieved = ivy.retrieve(md.getModuleRevisionId(), pattern, options);
         if (numberOfItemsRetrieved > 0) {
             // Only refresh if we actually retrieved a file.
             String refreshPath = IvyPatternHelper.getTokenRoot(retrievePattern);
@@ -318,12 +299,12 @@ public class IvyResolver {
         }
 
         // recompute the files which has been copied to build a classpath
-        String resolvedPattern = IvyPatternHelper.substituteVariables(pattern, getIvy()
-                .getSettings().getVariables());
+        String resolvedPattern = IvyPatternHelper.substituteVariables(pattern, ivy.getSettings()
+                .getVariables());
         try {
             // FIXME same as above
-            Map retrievedArtifacts = getIvy().getRetrieveEngine().determineArtifactsToCopy(
-                getMd().getModuleRevisionId(), resolvedPattern, options);
+            Map retrievedArtifacts = ivy.getRetrieveEngine().determineArtifactsToCopy(
+                md.getModuleRevisionId(), resolvedPattern, options);
             result.setRetrievedArtifacts(retrievedArtifacts);
         } catch (ParseException e) {
             // ooops, failed to parse a report we already have...

Modified: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/menu/RetrieveAction.java
URL: http://svn.apache.org/viewvc/ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/menu/RetrieveAction.java?rev=991977&r1=991976&r2=991977&view=diff
==============================================================================
--- ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/menu/RetrieveAction.java
(original)
+++ ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/menu/RetrieveAction.java
Thu Sep  2 15:20:22 2010
@@ -19,49 +19,34 @@ package org.apache.ivyde.eclipse.ui.menu
 
 import java.util.List;
 
-import org.apache.ivy.Ivy;
-import org.apache.ivy.core.module.descriptor.ModuleDescriptor;
-import org.apache.ivyde.eclipse.IvyMarkerManager;
 import org.apache.ivyde.eclipse.IvyPlugin;
 import org.apache.ivyde.eclipse.cpcontainer.IvyClasspathUtil;
+import org.apache.ivyde.eclipse.cpcontainer.IvyResolveJob;
+import org.apache.ivyde.eclipse.cpcontainer.ResolveRequest;
 import org.apache.ivyde.eclipse.resolve.IvyResolver;
 import org.apache.ivyde.eclipse.retrieve.RetrieveSetup;
 import org.apache.ivyde.eclipse.retrieve.StandaloneRetrieveSetup;
-import org.apache.ivyde.eclipse.retrieve.StandaloneRetrieveSetupState;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.NullProgressMonitor;
 import org.eclipse.jface.action.Action;
 
 public class RetrieveAction extends Action {
 
     private final StandaloneRetrieveSetup setup;
 
+    private IvyResolveJob ivyResolveJob;
+
     public RetrieveAction(StandaloneRetrieveSetup retrieveSetup) {
         this.setup = retrieveSetup;
+        ivyResolveJob = IvyPlugin.getDefault().getIvyResolveJob();
     }
 
     public void run() {
-        StandaloneRetrieveSetupState state = setup.getState();
-        Ivy ivy = state.getSafelyIvy();
-        if (ivy == null) {
-            return;
-        }
-        ModuleDescriptor md = state.getSafelyModuleDescriptor(ivy);
-        if (md == null) {
-            return;
-        }
         RetrieveSetup retrieveSetup = setup.getRetrieveSetup();
         List confs = IvyClasspathUtil.split(retrieveSetup.getRetrieveConfs());
-        IvyResolver resolver = new IvyResolver(ivy, setup.getIvyXmlPath(), md,
-                new NullProgressMonitor(), confs, setup.getProject());
-        IStatus status = resolver.resolve();
-        IvyMarkerManager ivyMarkerManager = IvyPlugin.getDefault().getIvyMarkerManager();
-        ivyMarkerManager.setResolveStatus(status, setup.getProject(), setup.getIvyXmlPath());
-        if (status.isOK() || status.getCode() == IStatus.CANCEL) {
-            IvyPlugin.log(IStatus.INFO, "Successful retrieve of '" + setup.getName() + "'
in "
-                    + setup.getProject().getName(), null);
-            return;
-        }
-        IvyPlugin.log(status);
+        IvyResolver resolver = new IvyResolver(setup.getIvyXmlPath(), confs, setup.getProject());
+        resolver.setRetrievePattern(retrieveSetup.getRetrievePattern());
+        resolver.setRetrieveSync(retrieveSetup.isRetrieveSync());
+        resolver.setRetrieveTypes(retrieveSetup.getRetrieveTypes());
+        ResolveRequest request = new ResolveRequest(resolver, setup.getState());
+        ivyResolveJob.addRequest(request);
     }
 }

Modified: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/workspaceresolver/WorkspaceResourceChangeListener.java
URL: http://svn.apache.org/viewvc/ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/workspaceresolver/WorkspaceResourceChangeListener.java?rev=991977&r1=991976&r2=991977&view=diff
==============================================================================
--- ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/workspaceresolver/WorkspaceResourceChangeListener.java
(original)
+++ ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/workspaceresolver/WorkspaceResourceChangeListener.java
Thu Sep  2 15:20:22 2010
@@ -26,8 +26,6 @@ import java.util.List;
 import org.apache.ivyde.eclipse.IvyPlugin;
 import org.apache.ivyde.eclipse.cpcontainer.IvyClasspathContainer;
 import org.apache.ivyde.eclipse.cpcontainer.IvyClasspathUtil;
-import org.apache.ivyde.eclipse.cpcontainer.IvyResolveJob;
-import org.apache.ivyde.eclipse.cpcontainer.ResolveRequest;
 import org.eclipse.core.resources.IFile;
 import org.eclipse.core.resources.IFolder;
 import org.eclipse.core.resources.IProject;
@@ -108,12 +106,10 @@ public class WorkspaceResourceChangeList
 
         List affectedContainers = getAffectedContainers(javaProject.getPath());
 
-        IvyResolveJob resolveJob = IvyPlugin.getDefault().getIvyResolveJob();
         Iterator it = affectedContainers.iterator();
         while (it.hasNext()) {
             IvyClasspathContainer ivycp = (IvyClasspathContainer) it.next();
-            ResolveRequest request = new ResolveRequest(ivycp, false);
-            resolveJob.addRequest(request);
+            ivycp.launchResolve(false, null);
         }
     }
 
@@ -157,12 +153,10 @@ public class WorkspaceResourceChangeList
         // dependent projects after the open operation has finished.
         List allContainers = getAllContainersExcludingProjects(projects);
 
-        IvyResolveJob resolveJob = IvyPlugin.getDefault().getIvyResolveJob();
         Iterator it = allContainers.iterator();
         while (it.hasNext()) {
             IvyClasspathContainer ivycp = (IvyClasspathContainer) it.next();
-            ResolveRequest request = new ResolveRequest(ivycp, false);
-            resolveJob.addRequest(request);
+            ivycp.launchResolve(false, null);
         }
     }
 



Mime
View raw message