handle("Unable to delete directory "
+ dir.getAbsolutePath());
}
}
}
Resources resourcesToDelete = new Resources();
resourcesToDelete.setProject(getProject());
resourcesToDelete.setCache(true);
Resources filesetDirs = new Resources();
filesetDirs.setProject(getProject());
filesetDirs.setCache(true);
FileSet implicit = null;
if (usedMatchingTask && dir != null && dir.isDirectory()) {
//add the files from the default fileset:
implicit = getImplicitFileSet();
implicit.setProject(getProject());
filesets.add(implicit);
}
final int size = filesets.size();
for (int i = 0; i < size; i++) {
FileSet fs = (FileSet) filesets.get(i);
if (fs.getProject() == null) {
log("Deleting fileset with no project specified;"
+ " assuming executing project", Project.MSG_VERBOSE);
fs = (FileSet) fs.clone();
fs.setProject(getProject());
}
final File fsDir = fs.getDir();
if (!fs.getErrorOnMissingDir() &&
(fsDir == null || !fsDir.exists())) {
continue;
}
if (fsDir == null) {
throw new BuildException(
"File or Resource without directory or file specified");
} else if (!fsDir.isDirectory()) {
handle("Directory does not exist: " + fsDir);
} else {
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<Resource> iterator() {
return new FileResourceIterator(getProject(),
fsDir, files);
}
});
if (includeEmpty) {
filesetDirs.add(new ReverseDirs(getProject(), fsDir,
ds
.getIncludedDirectories()));
}
if (removeNotFollowedSymlinks) {