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:
- java.lang.Cloneable,- SelectorContainer
 
 public class Delete extends MatchingTask 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 SummaryFields Modifier and Type Field Description protected java.io.Filedirprotected java.io.Filefileprotected java.util.Vector<FileSet>filesetsprotected booleanincludeEmptyprotected booleanusedMatchingTask- 
Fields inherited from class org.apache.tools.ant.taskdefs.MatchingTaskfileset
 - 
Fields inherited from class org.apache.tools.ant.ProjectComponentdescription, location, project
 
- 
 - 
Constructor SummaryConstructors Constructor Description Delete()
 - 
Method SummaryModifier and Type Method Description voidadd(ResourceCollection rc)Add 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 listPatternSet.NameEntrycreateExclude()add a name entry on the exclude listPatternSet.NameEntrycreateExcludesFile()add a name entry on the include files listPatternSet.NameEntrycreateInclude()add a name entry on the include listPatternSet.NameEntrycreateIncludesFile()add a name entry on the include files listPatternSetcreatePatternSet()add a set of patternsvoidexecute()Delete the file(s).protected voidremoveDir(java.io.File d)Delete a directoryprotected voidremoveFiles(java.io.File d, java.lang.String[] files, java.lang.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 continuevoidsetDir(java.io.File dir)Set the directory from which files are to be deletedvoidsetExcludes(java.lang.String excludes)Sets the set of exclude patterns.voidsetExcludesfile(java.io.File excludesfile)Sets the name of the file containing the includes patterns.voidsetFailOnError(boolean failonerror)If false, note errors but continue.voidsetFile(java.io.File file)Set 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(java.lang.String includes)Sets the set of include patterns.voidsetIncludesfile(java.io.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, XsetItems
 - 
Methods 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, setTaskType
 - 
Methods inherited from class org.apache.tools.ant.ProjectComponentclone, getDescription, getLocation, getProject, setDescription, setLocation
 
- 
 
- 
- 
- 
Field Detail- 
fileprotected java.io.File file 
 - 
dirprotected java.io.File dir 
 - 
filesetsprotected java.util.Vector<FileSet> filesets 
 - 
usedMatchingTaskprotected boolean usedMatchingTask 
 - 
includeEmptyprotected boolean includeEmpty 
 
- 
 - 
Method Detail- 
setFilepublic void setFile(java.io.File file) Set the name of a single file to be removed.- Parameters:
- file- the file to be deleted
 
 - 
setDirpublic void setDir(java.io.File dir) Set 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
 
 - 
addFilesetpublic void addFileset(FileSet set) Adds a set of files to be deleted.- Parameters:
- set- the set of files to be deleted
 
 - 
addpublic void add(ResourceCollection rc) Add an arbitrary ResourceCollection to be deleted.- Parameters:
- rc- the filesystem-only ResourceCollection.
 
 - 
createIncludepublic PatternSet.NameEntry createInclude() add a name entry on the include list- Overrides:
- createIncludein class- MatchingTask
- Returns:
- a NameEntry object to be configured
 
 - 
createIncludesFilepublic PatternSet.NameEntry createIncludesFile() add a name entry on the include files list- Overrides:
- createIncludesFilein class- MatchingTask
- Returns:
- a PatternFileNameEntry object to be configured
 
 - 
createExcludepublic PatternSet.NameEntry createExclude() add a name entry on the exclude list- Overrides:
- createExcludein class- MatchingTask
- Returns:
- a NameEntry object to be configured
 
 - 
createExcludesFilepublic PatternSet.NameEntry createExcludesFile() add a name entry on the include files list- Overrides:
- createExcludesFilein class- MatchingTask
- Returns:
- a PatternFileNameEntry object to be configured
 
 - 
createPatternSetpublic PatternSet createPatternSet() add a set of patterns- Overrides:
- createPatternSetin class- MatchingTask
- Returns:
- PatternSet object to be configured
 
 - 
setIncludespublic void setIncludes(java.lang.String includes) Sets 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
 
 - 
setExcludespublic void setExcludes(java.lang.String excludes) Sets 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.
 
 - 
setIncludesfilepublic void setIncludesfile(java.io.File includesfile) Sets 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.
 
 - 
setExcludesfilepublic void setExcludesfile(java.io.File excludesfile) Sets 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
 
 - 
addSelectorpublic void addSelector(SelectSelector selector) add a "Select" selector entry on the selector list- Specified by:
- addSelectorin interface- SelectorContainer
- Overrides:
- addSelectorin class- MatchingTask
- Parameters:
- selector- the selector to be added
 
 - 
addAndpublic void addAnd(AndSelector selector) add an "And" selector entry on the selector list- Specified by:
- addAndin interface- SelectorContainer
- Overrides:
- addAndin class- MatchingTask
- Parameters:
- selector- the selector to be added
 
 - 
addOrpublic void addOr(OrSelector selector) add an "Or" selector entry on the selector list- Specified by:
- addOrin interface- SelectorContainer
- Overrides:
- addOrin class- MatchingTask
- Parameters:
- selector- the selector to be added
 
 - 
addNotpublic void addNot(NotSelector selector) add a "Not" selector entry on the selector list- Specified by:
- addNotin interface- SelectorContainer
- Overrides:
- addNotin class- MatchingTask
- Parameters:
- selector- the selector to be added
 
 - 
addNonepublic void addNone(NoneSelector selector) add a "None" selector entry on the selector list- Specified by:
- addNonein interface- SelectorContainer
- Overrides:
- addNonein class- MatchingTask
- Parameters:
- selector- the selector to be added
 
 - 
addMajoritypublic void addMajority(MajoritySelector selector) add a majority selector entry on the selector list- Specified by:
- addMajorityin interface- SelectorContainer
- Overrides:
- addMajorityin class- MatchingTask
- Parameters:
- selector- the selector to be added
 
 - 
addDatepublic void addDate(DateSelector selector) add a selector date entry on the selector list- Specified by:
- addDatein interface- SelectorContainer
- Overrides:
- addDatein class- MatchingTask
- Parameters:
- selector- the selector to be added
 
 - 
addSizepublic void addSize(SizeSelector selector) add a selector size entry on the selector list- Specified by:
- addSizein interface- SelectorContainer
- Overrides:
- addSizein class- MatchingTask
- Parameters:
- selector- the selector to be added
 
 - 
addFilenamepublic void addFilename(FilenameSelector selector) add a selector filename entry on the selector list- Specified by:
- addFilenamein interface- SelectorContainer
- Overrides:
- addFilenamein class- MatchingTask
- Parameters:
- selector- the selector to be added
 
 - 
addCustompublic void addCustom(ExtendSelector selector) add an extended selector entry on the selector list- Specified by:
- addCustomin interface- SelectorContainer
- Overrides:
- addCustomin class- MatchingTask
- Parameters:
- selector- the selector to be added
 
 - 
addContainspublic void addContains(ContainsSelector selector) add a contains selector entry on the selector list- Specified by:
- addContainsin interface- SelectorContainer
- Overrides:
- addContainsin class- MatchingTask
- Parameters:
- selector- the selector to be added
 
 - 
addPresentpublic void addPresent(PresentSelector selector) add a present selector entry on the selector list- Specified by:
- addPresentin interface- SelectorContainer
- Overrides:
- addPresentin class- MatchingTask
- Parameters:
- selector- the selector to be added
 
 - 
addDepthpublic void addDepth(DepthSelector selector) add a depth selector entry on the selector list- Specified by:
- addDepthin interface- SelectorContainer
- Overrides:
- addDepthin class- MatchingTask
- Parameters:
- selector- the selector to be added
 
 - 
addDependpublic void addDepend(DependSelector selector) add a depends selector entry on the selector list- Specified by:
- addDependin interface- SelectorContainer
- Overrides:
- addDependin class- MatchingTask
- Parameters:
- selector- the selector to be added
 
 - 
addContainsRegexppublic void addContainsRegexp(ContainsRegexpSelector selector) add 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
 
 - 
addModifiedpublic void addModified(ModifiedSelector selector) add the modified selector- Specified by:
- addModifiedin interface- SelectorContainer
- Overrides:
- addModifiedin class- MatchingTask
- Parameters:
- selector- the selector to add
- Since:
- ant 1.6
 
 - 
addpublic void add(FileSelector selector) add an arbitrary selector- Specified by:
- addin interface- SelectorContainer
- Overrides:
- addin class- MatchingTask
- Parameters:
- selector- the selector to be added
- Since:
- Ant 1.6
 
 - 
executepublic void execute() throws BuildExceptionDelete the file(s).- Overrides:
- executein class- Task
- Throws:
- BuildException- if an error occurs
 
 - 
removeDirprotected void removeDir(java.io.File d) Delete a directory- Parameters:
- d- the directory to delete
 
 - 
removeFilesprotected void removeFiles(java.io.File d, java.lang.String[] files, java.lang.String[] dirs)remove 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
 
 
- 
 
-