ant-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hi...@apache.org
Subject svn commit: r1088279 - in /ant/ivy/ivyde/trunk: doc/release-notes.html org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/resolve/IvyResolver.java
Date Sun, 03 Apr 2011 13:12:35 GMT
Author: hibou
Date: Sun Apr  3 13:12:35 2011
New Revision: 1088279

URL: http://svn.apache.org/viewvc?rev=1088279&view=rev
Log:
IVYDE-272:
 - make the retrieve fail if the project is about to be wiped out

Modified:
    ant/ivy/ivyde/trunk/doc/release-notes.html
    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=1088279&r1=1088278&r2=1088279&view=diff
==============================================================================
--- ant/ivy/ivyde/trunk/doc/release-notes.html (original)
+++ ant/ivy/ivyde/trunk/doc/release-notes.html Sun Apr  3 13:12:35 2011
@@ -142,6 +142,7 @@ List of changes since <a href="/ivy/ivyd
     <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>
     <li>FIX: NPE when starting the IvyPlugin (IVYDE-269)</li>
+    <li>FIX: IvyDE deletes entirely a project if the retrieve pattern resolved to be
the root of the project (IVYDE-272)</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/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=1088279&r1=1088278&r2=1088279&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 13:12:35 2011
@@ -132,7 +132,10 @@ public class IvyResolver {
                     result = doResolve(ivy, md);
                 }
 
-                maybeRetrieve(ivy, md, result, monitor);
+                IStatus retrieveStatus = maybeRetrieve(ivy, md, result, monitor);
+                if (!retrieveStatus.isOK()) {
+                    return retrieveStatus;
+                }
 
                 postResolveOrRefresh(ivy, md, result, monitor);
             } catch (ParseException e) {
@@ -273,10 +276,10 @@ public class IvyResolver {
         }
     }
 
-    private void maybeRetrieve(Ivy ivy, ModuleDescriptor md, ResolveResult result,
+    private IStatus maybeRetrieve(Ivy ivy, ModuleDescriptor md, ResolveResult result,
             IProgressMonitor monitor) throws IOException {
         if (retrievePattern == null || project == null) {
-            return;
+            return Status.OK_STATUS;
         }
 
         String pattern = project.getLocation().toPortableString() + "/" + retrievePattern;
@@ -293,15 +296,24 @@ public class IvyResolver {
         }
         options.setResolveId(IvyClasspathUtil.buildResolveId(useExtendedResolveId, md));
 
+        String refreshPath = IvyPatternHelper.getTokenRoot(retrievePattern);
+        if (retrieveSync && refreshPath.length() == 0) {
+            // the root folder of the retrieve pattern is the the project itself
+            // so let's prevent from deleting the entire project
+            return new Status(IStatus.ERROR, IvyPlugin.ID, IStatus.ERROR,
+                    "The root of the retrieve pattern is the root folder of the project."
+                            + " Your project would have then been entirely deleted."
+                            + " Change your retrieve pattern to have a sub folder.", null);
+        }
+
         // 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 = ivy.retrieve(md.getModuleRevisionId(), pattern, options);
         if (numberOfItemsRetrieved > 0) {
             // Only refresh if we actually retrieved a file.
-            String refreshPath = IvyPatternHelper.getTokenRoot(retrievePattern);
-            IFolder folder = project.getFolder(refreshPath);
-            RefreshFolderJob refreshFolderJob = new RefreshFolderJob(folder);
+            IFolder retrieveFolder = project.getFolder(refreshPath);
+            RefreshFolderJob refreshFolderJob = new RefreshFolderJob(retrieveFolder);
             refreshFolderJob.schedule();
         }
 
@@ -315,9 +327,11 @@ public class IvyResolver {
             result.setRetrievedArtifacts(retrievedArtifacts);
         } catch (ParseException e) {
             // ooops, failed to parse a report we already have...
-            IvyPlugin.log(IStatus.ERROR,
-                "failed to parse a resolve report in order to do the retrieve", e);
+            return new Status(IStatus.ERROR, IvyPlugin.ID, IStatus.ERROR,
+                    "failed to parse a resolve report in order to do the retrieve", e);
         }
+
+        return Status.OK_STATUS;
     }
 
     /**



Mime
View raw message