ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mben...@apache.org
Subject svn commit: r292236 - in /ant/core/trunk/src: etc/testcases/taskdefs/delete.xml main/org/apache/tools/ant/taskdefs/Delete.java testcases/org/apache/tools/ant/taskdefs/DeleteTest.java
Date Wed, 28 Sep 2005 18:25:53 GMT
Author: mbenson
Date: Wed Sep 28 11:25:44 2005
New Revision: 292236

URL: http://svn.apache.org/viewcvs?rev=292236&view=rev
Log:
Don't try to delete nonexistent resources; switched to a single static
reverse filesystem ResourceComparator.

Modified:
    ant/core/trunk/src/etc/testcases/taskdefs/delete.xml
    ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Delete.java
    ant/core/trunk/src/testcases/org/apache/tools/ant/taskdefs/DeleteTest.java

Modified: ant/core/trunk/src/etc/testcases/taskdefs/delete.xml
URL: http://svn.apache.org/viewcvs/ant/core/trunk/src/etc/testcases/taskdefs/delete.xml?rev=292236&r1=292235&r2=292236&view=diff
==============================================================================
--- ant/core/trunk/src/etc/testcases/taskdefs/delete.xml (original)
+++ ant/core/trunk/src/etc/testcases/taskdefs/delete.xml Wed Sep 28 11:25:44 2005
@@ -103,6 +103,12 @@
     <expectabsent />
   </target>
 
+  <target name="test10">
+    <delete>
+      <filelist dir="${dir}" files="test10absentfile" />
+    </delete>
+  </target>
+
   <target name="cleanup" depends="test4" />
 
 </project>

Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Delete.java
URL: http://svn.apache.org/viewcvs/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Delete.java?rev=292236&r1=292235&r2=292236&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Delete.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Delete.java Wed Sep 28 11:25:44
2005
@@ -29,10 +29,14 @@
 import org.apache.tools.ant.types.PatternSet;
 import org.apache.tools.ant.types.ResourceCollection;
 import org.apache.tools.ant.types.resources.Sort;
+import org.apache.tools.ant.types.resources.Restrict;
 import org.apache.tools.ant.types.resources.BCFileSet;
 import org.apache.tools.ant.types.resources.FileResource;
 import org.apache.tools.ant.types.resources.comparators.Reverse;
 import org.apache.tools.ant.types.resources.comparators.FileSystem;
+import org.apache.tools.ant.types.resources.comparators.ResourceComparator;
+import org.apache.tools.ant.types.resources.selectors.Exists;
+import org.apache.tools.ant.types.resources.selectors.ResourceSelector;
 import org.apache.tools.ant.types.selectors.OrSelector;
 import org.apache.tools.ant.types.selectors.AndSelector;
 import org.apache.tools.ant.types.selectors.NotSelector;
@@ -67,6 +71,9 @@
  */
 public class Delete extends MatchingTask {
     private static final int DELETE_RETRY_SLEEP_MILLIS = 10;
+    private static final ResourceComparator REVERSE_FILESYSTEM = new Reverse(new FileSystem());
+    private static final ResourceSelector EXISTS = new Exists();
+
     protected File file = null;
     protected File dir = null;
     protected Vector filesets = new Vector();
@@ -525,10 +532,13 @@
             FileSet implicit = getImplicitFileSet();
             p.add(includeEmpty ? new BCFileSet(implicit) : implicit);
         }
+        Restrict e = new Restrict();
+        e.add(EXISTS);
+        e.add(p);
         // delete the files in the resource collections; sort to files, then dirs
         Sort s = new Sort();
-        s.add(new Reverse(new FileSystem()));
-        s.add(p);
+        s.add(REVERSE_FILESYSTEM);
+        s.add(e);
         for (Iterator iter = s.iterator(); iter.hasNext();) {
             FileResource r = (FileResource) iter.next();
             if (!(r.isDirectory()) || r.getFile().list().length == 0) {

Modified: ant/core/trunk/src/testcases/org/apache/tools/ant/taskdefs/DeleteTest.java
URL: http://svn.apache.org/viewcvs/ant/core/trunk/src/testcases/org/apache/tools/ant/taskdefs/DeleteTest.java?rev=292236&r1=292235&r2=292236&view=diff
==============================================================================
--- ant/core/trunk/src/testcases/org/apache/tools/ant/taskdefs/DeleteTest.java (original)
+++ ant/core/trunk/src/testcases/org/apache/tools/ant/taskdefs/DeleteTest.java Wed Sep 28
11:25:44 2005
@@ -61,4 +61,7 @@
     public void test9() {
         executeTarget("test9");
     }
+    public void test10() {
+        executeTarget("test10");
+    }
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org


Mime
View raw message