fixed. Bugzilla 40313. git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@468724 13f79535-47bb-0310-9956-ffa450edef68master
@@ -10,6 +10,9 @@ Fixed bugs: | |||||
* OOM caused by IH holding on to classes and thus their classloaders. | * OOM caused by IH holding on to classes and thus their classloaders. | ||||
Bugzilla 28283 and 33061. | Bugzilla 28283 and 33061. | ||||
* <delete> doesnt delete when defaultexcludes="false" and no includes is set | |||||
fixed. Bugzilla 40313. | |||||
Other changes: | Other changes: | ||||
-------------- | -------------- | ||||
@@ -6,10 +6,11 @@ | |||||
<property name="dir" location="${dirname}" /> | <property name="dir" location="${dirname}" /> | ||||
<macrodef name="expectabsent"> | <macrodef name="expectabsent"> | ||||
<attribute name="target" default="${dir}"/> | |||||
<sequential> | <sequential> | ||||
<fail> | <fail> | ||||
<condition> | <condition> | ||||
<available file="${dir}" /> | |||||
<available file="@{target}" /> | |||||
</condition> | </condition> | ||||
</fail> | </fail> | ||||
</sequential> | </sequential> | ||||
@@ -142,6 +143,30 @@ | |||||
<fileset dir="${dir}" /> | <fileset dir="${dir}" /> | ||||
</delete> | </delete> | ||||
</target> | </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" /> | <target name="cleanup" depends="test4" /> | ||||
@@ -544,6 +544,13 @@ public class Delete extends MatchingTask { | |||||
resourcesToDelete.setProject(getProject()); | resourcesToDelete.setProject(getProject()); | ||||
Resources filesetDirs = new Resources(); | Resources filesetDirs = new Resources(); | ||||
filesetDirs.setProject(getProject()); | 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++) { | for (int i = 0, size = filesets.size(); i < size; i++) { | ||||
FileSet fs = (FileSet) filesets.get(i); | FileSet fs = (FileSet) filesets.get(i); | ||||
@@ -559,15 +566,6 @@ public class Delete extends MatchingTask { | |||||
fs.getDirectoryScanner().getIncludedDirectories())); | 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); | resourcesToDelete.add(filesetDirs); | ||||
if (rcs != null) { | if (rcs != null) { | ||||
// sort first to files, then dirs | // sort first to files, then dirs | ||||
@@ -601,7 +599,11 @@ public class Delete extends MatchingTask { | |||||
} | } | ||||
} catch (Exception e) { | } catch (Exception e) { | ||||
handle(e); | handle(e); | ||||
} | |||||
} finally { | |||||
if (implicit != null) { | |||||
filesets.remove(implicit); | |||||
} | |||||
} | |||||
} | } | ||||
//************************************************************************ | //************************************************************************ | ||||
@@ -80,4 +80,10 @@ public class DeleteTest extends BuildFileTest { | |||||
public void test15() { | public void test15() { | ||||
executeTarget("test15"); | executeTarget("test15"); | ||||
} | } | ||||
public void test16() { | |||||
executeTarget("test16"); | |||||
} | |||||
public void test17() { | |||||
executeTarget("test17"); | |||||
} | |||||
} | } |