git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@806442 13f79535-47bb-0310-9956-ffa450edef68master
| @@ -597,15 +597,30 @@ public class Delete extends MatchingTask { | |||||
| fs = (FileSet) fs.clone(); | fs = (FileSet) fs.clone(); | ||||
| fs.setProject(getProject()); | fs.setProject(getProject()); | ||||
| } | } | ||||
| File fsDir = fs.getDir(); | |||||
| final File fsDir = fs.getDir(); | |||||
| if (fsDir == null) { | if (fsDir == null) { | ||||
| throw new BuildException( | throw new BuildException( | ||||
| "File or Resource without directory or file specified"); | "File or Resource without directory or file specified"); | ||||
| } else if (!fsDir.isDirectory()) { | } else if (!fsDir.isDirectory()) { | ||||
| handle("Directory does not exist: " + fsDir); | handle("Directory does not exist: " + fsDir); | ||||
| } else { | } else { | ||||
| resourcesToDelete.add(fs); | |||||
| DirectoryScanner ds = fs.getDirectoryScanner(); | DirectoryScanner ds = fs.getDirectoryScanner(); | ||||
| // the previous line has already scanned the | |||||
| // filesystem, in order to avoid a rescan when later | |||||
| // iterating, capture the results now and store them | |||||
| final String[] files = ds.getIncludedFiles(); | |||||
| resourcesToDelete.add(new ResourceCollection() { | |||||
| public boolean isFilesystemOnly() { | |||||
| return true; | |||||
| } | |||||
| public int size() { | |||||
| return files.length; | |||||
| } | |||||
| public Iterator iterator() { | |||||
| return new FileResourceIterator(getProject(), | |||||
| fsDir, files); | |||||
| } | |||||
| }); | |||||
| if (includeEmpty) { | if (includeEmpty) { | ||||
| filesetDirs.add(new ReverseDirs(getProject(), fsDir, | filesetDirs.add(new ReverseDirs(getProject(), fsDir, | ||||
| ds | ds | ||||
| @@ -150,4 +150,42 @@ public class NullByteStreamResource extends Resource { | |||||
| </copy> | </copy> | ||||
| </au:expectfailure> | </au:expectfailure> | ||||
| </target> | </target> | ||||
| <target name="testNotModifiedSelector" | |||||
| description="https://issues.apache.org/bugzilla/show_bug.cgi?id=43574" | |||||
| > | |||||
| <mkdir dir="${input}/images"/> | |||||
| <mkdir dir="${input}/cache"/> | |||||
| <touch file="${input}/images/foo.jpg"/> | |||||
| <mkdir dir="${output}"/> | |||||
| <selector id="cache.selector"> | |||||
| <not> | |||||
| <modified update="true" | |||||
| seldirs="false" | |||||
| cache="propertyfile" | |||||
| algorithm="digest" | |||||
| comparator="equal"> | |||||
| <param name="cache.cachefile" | |||||
| value="${input}/cache/cache.properties"/> | |||||
| <param name="algorithm.algorithm" value="MD5"/> | |||||
| </modified> | |||||
| </not> | |||||
| </selector> | |||||
| <au:assertFileDoesntExist file="${input}/cache/cache.properties"/> | |||||
| <copy todir="${output}" overwrite="true"> | |||||
| <fileset dir="${input}/images"> | |||||
| <include name="*.jpg" /> | |||||
| <selector refid="cache.selector" /> | |||||
| </fileset> | |||||
| </copy> | |||||
| <au:assertFileExists file="${input}/cache/cache.properties"/> | |||||
| <au:assertFileDoesntExist file="${output}/foo.jpg"/> | |||||
| <copy todir="${output}" overwrite="true"> | |||||
| <fileset dir="${input}/images"> | |||||
| <include name="*.jpg" /> | |||||
| <selector refid="cache.selector" /> | |||||
| </fileset> | |||||
| </copy> | |||||
| <au:assertFileExists file="${output}/foo.jpg"/> | |||||
| </target> | |||||
| </project> | </project> | ||||
| @@ -94,4 +94,41 @@ | |||||
| <touch file="${output}/foo"/> | <touch file="${output}/foo"/> | ||||
| <au:assertFileDoesntExist file="${output}/link" /> | <au:assertFileDoesntExist file="${output}/link" /> | ||||
| </target> | </target> | ||||
| <target name="testNotModifiedSelector" | |||||
| description="https://issues.apache.org/bugzilla/show_bug.cgi?id=43574" | |||||
| > | |||||
| <mkdir dir="${input}/images"/> | |||||
| <mkdir dir="${input}/cache"/> | |||||
| <touch file="${input}/images/foo.jpg"/> | |||||
| <selector id="cache.selector"> | |||||
| <not> | |||||
| <modified update="true" | |||||
| seldirs="false" | |||||
| cache="propertyfile" | |||||
| algorithm="digest" | |||||
| comparator="equal"> | |||||
| <param name="cache.cachefile" | |||||
| value="${input}/cache/cache.properties"/> | |||||
| <param name="algorithm.algorithm" value="MD5"/> | |||||
| </modified> | |||||
| </not> | |||||
| </selector> | |||||
| <au:assertFileDoesntExist file="${input}/cache/cache.properties"/> | |||||
| <delete> | |||||
| <fileset dir="${input}/images"> | |||||
| <include name="*.jpg" /> | |||||
| <selector refid="cache.selector" /> | |||||
| </fileset> | |||||
| </delete> | |||||
| <au:assertFileExists file="${input}/cache/cache.properties"/> | |||||
| <au:assertFileExists file="${input}/images/foo.jpg"/> | |||||
| <delete> | |||||
| <fileset dir="${input}/images"> | |||||
| <include name="*.jpg" /> | |||||
| <selector refid="cache.selector" /> | |||||
| </fileset> | |||||
| </delete> | |||||
| <au:assertFileDoesntExist file="${input}/images/foo.jpg"/> | |||||
| </target> | |||||
| </project> | </project> | ||||
| @@ -59,4 +59,43 @@ | |||||
| <au:assertFileExists file="${output}/foo/bar/baz.txt"/> | <au:assertFileExists file="${output}/foo/bar/baz.txt"/> | ||||
| </target> | </target> | ||||
| <target name="testNotModifiedSelector" | |||||
| description="https://issues.apache.org/bugzilla/show_bug.cgi?id=43574" | |||||
| > | |||||
| <mkdir dir="${input}/images"/> | |||||
| <mkdir dir="${input}/cache"/> | |||||
| <touch file="${input}/images/foo.jpg"/> | |||||
| <mkdir dir="${output}"/> | |||||
| <selector id="cache.selector"> | |||||
| <not> | |||||
| <modified update="true" | |||||
| seldirs="false" | |||||
| cache="propertyfile" | |||||
| algorithm="digest" | |||||
| comparator="equal"> | |||||
| <param name="cache.cachefile" | |||||
| value="${input}/cache/cache.properties"/> | |||||
| <param name="algorithm.algorithm" value="MD5"/> | |||||
| </modified> | |||||
| </not> | |||||
| </selector> | |||||
| <au:assertFileDoesntExist file="${input}/cache/cache.properties"/> | |||||
| <move todir="${output}" overwrite="true"> | |||||
| <fileset dir="${input}/images"> | |||||
| <include name="*.jpg" /> | |||||
| <selector refid="cache.selector" /> | |||||
| </fileset> | |||||
| </move> | |||||
| <au:assertFileExists file="${input}/cache/cache.properties"/> | |||||
| <au:assertFileExists file="${input}/images/foo.jpg"/> | |||||
| <au:assertFileDoesntExist file="${output}/foo.jpg"/> | |||||
| <move todir="${output}" overwrite="true"> | |||||
| <fileset dir="${input}/images"> | |||||
| <include name="*.jpg" /> | |||||
| <selector refid="cache.selector" /> | |||||
| </fileset> | |||||
| </move> | |||||
| <au:assertFileDoesntExist file="${input}/images/foo.jpg"/> | |||||
| <au:assertFileExists file="${output}/foo.jpg"/> | |||||
| </target> | |||||
| </project> | </project> | ||||