ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From anto...@apache.org
Subject svn commit: r468724 - in /ant/core/trunk: WHATSNEW src/etc/testcases/taskdefs/delete.xml src/main/org/apache/tools/ant/taskdefs/Delete.java src/tests/junit/org/apache/tools/ant/taskdefs/DeleteTest.java
Date Sat, 28 Oct 2006 19:07:23 GMT
Author: antoine
Date: Sat Oct 28 12:07:22 2006
New Revision: 468724

URL: http://svn.apache.org/viewvc?view=rev&rev=468724
Log:
<delete> doesnt delete when defaultexcludes="false" and no includes is set 
fixed. Bugzilla 40313.

Modified:
    ant/core/trunk/WHATSNEW
    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/tests/junit/org/apache/tools/ant/taskdefs/DeleteTest.java

Modified: ant/core/trunk/WHATSNEW
URL: http://svn.apache.org/viewvc/ant/core/trunk/WHATSNEW?view=diff&rev=468724&r1=468723&r2=468724
==============================================================================
--- ant/core/trunk/WHATSNEW (original)
+++ ant/core/trunk/WHATSNEW Sat Oct 28 12:07:22 2006
@@ -10,6 +10,9 @@
 * OOM caused by IH holding on to classes and thus their classloaders.
   Bugzilla 28283 and 33061.
 
+* <delete> doesnt delete when defaultexcludes="false" and no includes is set 
+  fixed. Bugzilla 40313.
+
 Other changes:
 --------------
 

Modified: ant/core/trunk/src/etc/testcases/taskdefs/delete.xml
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/etc/testcases/taskdefs/delete.xml?view=diff&rev=468724&r1=468723&r2=468724
==============================================================================
--- ant/core/trunk/src/etc/testcases/taskdefs/delete.xml (original)
+++ ant/core/trunk/src/etc/testcases/taskdefs/delete.xml Sat Oct 28 12:07:22 2006
@@ -6,10 +6,11 @@
   <property name="dir" location="${dirname}" />
 
   <macrodef name="expectabsent">
+    <attribute name="target" default="${dir}"/>
     <sequential>
       <fail>
         <condition>
-          <available file="${dir}" />
+          <available file="@{target}" />
         </condition>
     </fail>
     </sequential>
@@ -142,6 +143,30 @@
 		<fileset dir="${dir}" />
 	</delete>
   </target>
+  <!-- Bugzilla 40313 -->
+  <target name="test16.init">
+    <mkdir dir="${dir}/CVS"/>
+    <touch file="${dir}/CVS/lala"/>
+    <mkdir dir="${dir}/subdir"/>
+  </target>
+
+  <target name="test16" depends="test16.init">
+    <delete defaultexcludes="false" dir="${dir}" includeemptydirs="true"/>
+    <expectabsent/>
+  </target>
+
+  <target name="test17" depends="test16.init">
+    <delete dir="${dir}" defaultexcludes="true" includeemptydirs="true"/>
+    <fail message="file in CVS dir deleted">
+      <condition>
+        <not>
+          <available file="${dir}/CVS/lala"/>
+        </not>
+      </condition>
+    </fail>
+    <expectabsent target="${dir}/subdir"/>
+  </target>
+
 
   <target name="cleanup" depends="test4" />
 

Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Delete.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Delete.java?view=diff&rev=468724&r1=468723&r2=468724
==============================================================================
--- 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 Sat Oct 28 12:07:22
2006
@@ -544,6 +544,13 @@
         resourcesToDelete.setProject(getProject());
         Resources filesetDirs = new Resources();
         filesetDirs.setProject(getProject());
+        FileSet implicit = null;
+        if (usedMatchingTask && dir != null && dir.isDirectory()) {
+            //add the files from the default fileset:
+            implicit = getImplicitFileSet();
+            implicit.setProject(getProject());
+            filesets.add(implicit);
+        }
 
         for (int i = 0, size = filesets.size(); i < size; i++) {
             FileSet fs = (FileSet) filesets.get(i);
@@ -559,15 +566,6 @@
                   fs.getDirectoryScanner().getIncludedDirectories()));
             }
         }
-        if (usedMatchingTask && dir != null && dir.isDirectory()) {
-            //add the files from the default fileset:
-            FileSet implicit = getImplicitFileSet();
-            resourcesToDelete.add(implicit);
-            if (includeEmpty) {
-              filesetDirs.add(new ReverseDirs(dir,
-                  implicit.getDirectoryScanner().getIncludedDirectories()));
-            }
-        }
         resourcesToDelete.add(filesetDirs);
         if (rcs != null) {
             // sort first to files, then dirs
@@ -601,7 +599,11 @@
             }
         } catch (Exception e) {
             handle(e);
-        }
+        } finally {
+	    if (implicit != null) {
+		filesets.remove(implicit);
+	    }
+	}
     }
 
 //************************************************************************

Modified: ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/DeleteTest.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/DeleteTest.java?view=diff&rev=468724&r1=468723&r2=468724
==============================================================================
--- ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/DeleteTest.java (original)
+++ ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/DeleteTest.java Sat Oct 28
12:07:22 2006
@@ -80,4 +80,10 @@
     public void test15() {
         executeTarget("test15");
     }
+    public void test16() {
+        executeTarget("test16");
+    }
+    public void test17() {
+        executeTarget("test17");
+    }
 }



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


Mime
View raw message