Package org.apache.tools.ant.taskdefs
Class Delete
java.lang.Object
org.apache.tools.ant.ProjectComponent
org.apache.tools.ant.Task
org.apache.tools.ant.taskdefs.MatchingTask
org.apache.tools.ant.taskdefs.Delete
- All Implemented Interfaces:
- Cloneable,- SelectorContainer
Deletes a file or directory, or set of files defined by a fileset.
 The original delete task would delete a file, or a set of files
 using the include/exclude syntax.  The deltree task would delete a
 directory tree.  This task combines the functionality of these two
 originally distinct tasks.
 
Currently Delete extends MatchingTask. This is intended only to provide backwards compatibility for a release. The future position is to use nested filesets exclusively.
- Since:
- Ant 1.2
- 
Field SummaryFieldsModifier and TypeFieldDescriptionprotected Fileprotected Fileprotected booleanprotected booleanFields inherited from class org.apache.tools.ant.taskdefs.MatchingTaskfilesetFields inherited from class org.apache.tools.ant.ProjectComponentdescription, location, project
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionvoidAdd an arbitrary ResourceCollection to be deleted.voidadd(FileSelector selector) add an arbitrary selectorvoidaddAnd(AndSelector selector) add an "And" selector entry on the selector listvoidaddContains(ContainsSelector selector) add a contains selector entry on the selector listvoidaddContainsRegexp(ContainsRegexpSelector selector) add a regular expression selector entry on the selector listvoidaddCustom(ExtendSelector selector) add an extended selector entry on the selector listvoidaddDate(DateSelector selector) add a selector date entry on the selector listvoidaddDepend(DependSelector selector) add a depends selector entry on the selector listvoidaddDepth(DepthSelector selector) add a depth selector entry on the selector listvoidaddFilename(FilenameSelector selector) add a selector filename entry on the selector listvoidaddFileset(FileSet set) Adds a set of files to be deleted.voidaddMajority(MajoritySelector selector) add a majority selector entry on the selector listvoidaddModified(ModifiedSelector selector) add the modified selectorvoidaddNone(NoneSelector selector) add a "None" selector entry on the selector listvoidaddNot(NotSelector selector) add a "Not" selector entry on the selector listvoidaddOr(OrSelector selector) add an "Or" selector entry on the selector listvoidaddPresent(PresentSelector selector) add a present selector entry on the selector listvoidaddSelector(SelectSelector selector) add a "Select" selector entry on the selector listvoidaddSize(SizeSelector selector) add a selector size entry on the selector listadd a name entry on the exclude listadd a name entry on the include files listadd a name entry on the include listadd a name entry on the include files listadd a set of patternsvoidexecute()Delete the file(s).protected voidDelete a directoryprotected voidremoveFiles(File d, String[] files, String[] dirs) remove an array of files in a directory, and a list of subdirectories which will only be deleted if 'includeEmpty' is truevoidsetCaseSensitive(boolean isCaseSensitive) Sets case sensitivity of the file systemvoidsetDefaultexcludes(boolean useDefaultExcludes) Sets whether default exclusions should be used or not.voidsetDeleteOnExit(boolean deleteOnExit) If true, on failure to delete, note the error and set the deleteonexit flag, and continuevoidSet the directory from which files are to be deletedvoidsetExcludes(String excludes) Sets the set of exclude patterns.voidsetExcludesfile(File excludesfile) Sets the name of the file containing the includes patterns.voidsetFailOnError(boolean failonerror) If false, note errors but continue.voidSet the name of a single file to be removed.voidsetFollowSymlinks(boolean followSymlinks) Sets whether or not symbolic links should be followed.voidsetIncludeEmptyDirs(boolean includeEmpty) If true, delete empty directories.voidsetIncludes(String includes) Sets the set of include patterns.voidsetIncludesfile(File includesfile) Sets the name of the file containing the includes patterns.voidsetPerformGcOnFailedDelete(boolean b) Whether to perform a garbage collection before retrying a failed delete.voidsetQuiet(boolean quiet) If true and the file does not exist, do not display a diagnostic message or modify the exit status to reflect an error.voidsetRemoveNotFollowedSymlinks(boolean b) Sets whether the symbolic links that have not been followed shall be removed (the links, not the locations they point at).voidsetVerbose(boolean verbose) If true, list all names of deleted files.Methods inherited from class org.apache.tools.ant.taskdefs.MatchingTaskaddDifferent, addType, appendSelector, getDirectoryScanner, getImplicitFileSet, getSelectors, hasSelectors, selectorCount, selectorElements, setProject, XsetIgnore, XsetItemsMethods inherited from class org.apache.tools.ant.TaskbindToOwner, getOwningTarget, getRuntimeConfigurableWrapper, getTaskName, getTaskType, getWrapper, handleErrorFlush, handleErrorOutput, handleFlush, handleInput, handleOutput, init, isInvalid, log, log, log, log, maybeConfigure, perform, reconfigure, setOwningTarget, setRuntimeConfigurableWrapper, setTaskName, setTaskTypeMethods inherited from class org.apache.tools.ant.ProjectComponentclone, getDescription, getLocation, getProject, setDescription, setLocation
- 
Field Details- 
file
- 
dir
- 
filesets
- 
usedMatchingTaskprotected boolean usedMatchingTask
- 
includeEmptyprotected boolean includeEmpty
 
- 
- 
Constructor Details- 
Deletepublic Delete()
 
- 
- 
Method Details- 
setFileSet the name of a single file to be removed.- Parameters:
- file- the file to be deleted
 
- 
setDirSet the directory from which files are to be deleted- Parameters:
- dir- the directory path.
 
- 
setVerbosepublic void setVerbose(boolean verbose) If true, list all names of deleted files.- Parameters:
- verbose- "true" or "on"
 
- 
setQuietpublic void setQuiet(boolean quiet) If true and the file does not exist, do not display a diagnostic message or modify the exit status to reflect an error. This means that if a file or directory cannot be deleted, then no error is reported. This setting emulates the -f option to the Unix "rm" command. Default is false meaning things are "noisy"- Parameters:
- quiet- "true" or "on"
 
- 
setFailOnErrorpublic void setFailOnError(boolean failonerror) If false, note errors but continue.- Parameters:
- failonerror- true or false
 
- 
setDeleteOnExitpublic void setDeleteOnExit(boolean deleteOnExit) If true, on failure to delete, note the error and set the deleteonexit flag, and continue- Parameters:
- deleteOnExit- true or false
 
- 
setIncludeEmptyDirspublic void setIncludeEmptyDirs(boolean includeEmpty) If true, delete empty directories.- Parameters:
- includeEmpty- if true delete empty directories (only for filesets). Default is false.
 
- 
setPerformGcOnFailedDeletepublic void setPerformGcOnFailedDelete(boolean b) Whether to perform a garbage collection before retrying a failed delete.This may be required on Windows (where it is set to true by default) but also on other operating systems, for example when deleting directories from an NFS share. - Parameters:
- b- boolean
- Since:
- Ant 1.8.3
 
- 
addFilesetAdds a set of files to be deleted.- Parameters:
- set- the set of files to be deleted
 
- 
addAdd an arbitrary ResourceCollection to be deleted.- Parameters:
- rc- the filesystem-only ResourceCollection.
 
- 
createIncludeadd a name entry on the include list- Overrides:
- createIncludein class- MatchingTask
- Returns:
- a NameEntry object to be configured
 
- 
createIncludesFileadd a name entry on the include files list- Overrides:
- createIncludesFilein class- MatchingTask
- Returns:
- a PatternFileNameEntry object to be configured
 
- 
createExcludeadd a name entry on the exclude list- Overrides:
- createExcludein class- MatchingTask
- Returns:
- a NameEntry object to be configured
 
- 
createExcludesFileadd a name entry on the include files list- Overrides:
- createExcludesFilein class- MatchingTask
- Returns:
- a PatternFileNameEntry object to be configured
 
- 
createPatternSetadd a set of patterns- Overrides:
- createPatternSetin class- MatchingTask
- Returns:
- PatternSet object to be configured
 
- 
setIncludesSets the set of include patterns. Patterns may be separated by a comma or a space.- Overrides:
- setIncludesin class- MatchingTask
- Parameters:
- includes- the string containing the include patterns
 
- 
setExcludesSets the set of exclude patterns. Patterns may be separated by a comma or a space.- Overrides:
- setExcludesin class- MatchingTask
- Parameters:
- excludes- the string containing the exclude patterns
 
- 
setDefaultexcludespublic void setDefaultexcludes(boolean useDefaultExcludes) Sets whether default exclusions should be used or not.- Overrides:
- setDefaultexcludesin class- MatchingTask
- Parameters:
- useDefaultExcludes- "true"|"on"|"yes" when default exclusions should be used, "false"|"off"|"no" when they shouldn't be used.
 
- 
setIncludesfileSets the name of the file containing the includes patterns.- Overrides:
- setIncludesfilein class- MatchingTask
- Parameters:
- includesfile- A string containing the filename to fetch the include patterns from.
 
- 
setExcludesfileSets the name of the file containing the includes patterns.- Overrides:
- setExcludesfilein class- MatchingTask
- Parameters:
- excludesfile- A string containing the filename to fetch the include patterns from.
 
- 
setCaseSensitivepublic void setCaseSensitive(boolean isCaseSensitive) Sets case sensitivity of the file system- Overrides:
- setCaseSensitivein class- MatchingTask
- Parameters:
- isCaseSensitive- "true"|"on"|"yes" if file system is case sensitive, "false"|"off"|"no" when not.
 
- 
setFollowSymlinkspublic void setFollowSymlinks(boolean followSymlinks) Sets whether or not symbolic links should be followed.- Overrides:
- setFollowSymlinksin class- MatchingTask
- Parameters:
- followSymlinks- whether or not symbolic links should be followed
 
- 
setRemoveNotFollowedSymlinkspublic void setRemoveNotFollowedSymlinks(boolean b) Sets whether the symbolic links that have not been followed shall be removed (the links, not the locations they point at).- Parameters:
- b- boolean
- Since:
- Ant 1.8.0
 
- 
addSelectoradd a "Select" selector entry on the selector list- Specified by:
- addSelectorin interface- SelectorContainer
- Overrides:
- addSelectorin class- MatchingTask
- Parameters:
- selector- the selector to be added
 
- 
addAndadd an "And" selector entry on the selector list- Specified by:
- addAndin interface- SelectorContainer
- Overrides:
- addAndin class- MatchingTask
- Parameters:
- selector- the selector to be added
 
- 
addOradd an "Or" selector entry on the selector list- Specified by:
- addOrin interface- SelectorContainer
- Overrides:
- addOrin class- MatchingTask
- Parameters:
- selector- the selector to be added
 
- 
addNotadd a "Not" selector entry on the selector list- Specified by:
- addNotin interface- SelectorContainer
- Overrides:
- addNotin class- MatchingTask
- Parameters:
- selector- the selector to be added
 
- 
addNoneadd a "None" selector entry on the selector list- Specified by:
- addNonein interface- SelectorContainer
- Overrides:
- addNonein class- MatchingTask
- Parameters:
- selector- the selector to be added
 
- 
addMajorityadd a majority selector entry on the selector list- Specified by:
- addMajorityin interface- SelectorContainer
- Overrides:
- addMajorityin class- MatchingTask
- Parameters:
- selector- the selector to be added
 
- 
addDateadd a selector date entry on the selector list- Specified by:
- addDatein interface- SelectorContainer
- Overrides:
- addDatein class- MatchingTask
- Parameters:
- selector- the selector to be added
 
- 
addSizeadd a selector size entry on the selector list- Specified by:
- addSizein interface- SelectorContainer
- Overrides:
- addSizein class- MatchingTask
- Parameters:
- selector- the selector to be added
 
- 
addFilenameadd a selector filename entry on the selector list- Specified by:
- addFilenamein interface- SelectorContainer
- Overrides:
- addFilenamein class- MatchingTask
- Parameters:
- selector- the selector to be added
 
- 
addCustomadd an extended selector entry on the selector list- Specified by:
- addCustomin interface- SelectorContainer
- Overrides:
- addCustomin class- MatchingTask
- Parameters:
- selector- the selector to be added
 
- 
addContainsadd a contains selector entry on the selector list- Specified by:
- addContainsin interface- SelectorContainer
- Overrides:
- addContainsin class- MatchingTask
- Parameters:
- selector- the selector to be added
 
- 
addPresentadd a present selector entry on the selector list- Specified by:
- addPresentin interface- SelectorContainer
- Overrides:
- addPresentin class- MatchingTask
- Parameters:
- selector- the selector to be added
 
- 
addDepthadd a depth selector entry on the selector list- Specified by:
- addDepthin interface- SelectorContainer
- Overrides:
- addDepthin class- MatchingTask
- Parameters:
- selector- the selector to be added
 
- 
addDependadd a depends selector entry on the selector list- Specified by:
- addDependin interface- SelectorContainer
- Overrides:
- addDependin class- MatchingTask
- Parameters:
- selector- the selector to be added
 
- 
addContainsRegexpadd a regular expression selector entry on the selector list- Specified by:
- addContainsRegexpin interface- SelectorContainer
- Overrides:
- addContainsRegexpin class- MatchingTask
- Parameters:
- selector- the selector to be added
 
- 
addModifiedadd the modified selector- Specified by:
- addModifiedin interface- SelectorContainer
- Overrides:
- addModifiedin class- MatchingTask
- Parameters:
- selector- the selector to add
- Since:
- ant 1.6
 
- 
addadd an arbitrary selector- Specified by:
- addin interface- SelectorContainer
- Overrides:
- addin class- MatchingTask
- Parameters:
- selector- the selector to be added
- Since:
- Ant 1.6
 
- 
executeDelete the file(s).- Overrides:
- executein class- Task
- Throws:
- BuildException- if an error occurs
 
- 
removeDirDelete a directory- Parameters:
- d- the directory to delete
 
- 
removeFilesremove an array of files in a directory, and a list of subdirectories which will only be deleted if 'includeEmpty' is true- Parameters:
- d- directory to work from
- files- array of files to delete; can be of zero length
- dirs- array of directories to delete; can of zero length
 
 
-