org.apache.tools.ant.taskdefs

Class Delete

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

UNKNOWN: category="filesystem"

Field Summary
protected Filedir
protected Filefile
protected Vectorfilesets
protected booleanincludeEmpty
protected booleanusedMatchingTask
Method Summary
voidadd(FileSelector selector)
add an arbitrary selector
voidaddAnd(AndSelector selector)
add an "And" selector entry on the selector list
voidaddContains(ContainsSelector selector)
add a contains selector entry on the selector list
voidaddContainsRegexp(ContainsRegexpSelector selector)
add a regular expression selector entry on the selector list
voidaddCustom(ExtendSelector selector)
add an extended selector entry on the selector list
voidaddDate(DateSelector selector)
add a selector date entry on the selector list
voidaddDepend(DependSelector selector)
add a depends selector entry on the selector list
voidaddDepth(DepthSelector selector)
add a depth selector entry on the selector list
voidaddFilename(FilenameSelector selector)
add a selector filename entry on the selector list
voidaddFileset(FileSet set)
Adds a set of files to be deleted.
voidaddMajority(MajoritySelector selector)
add a majority selector entry on the selector list
voidaddModified(ModifiedSelector selector)
add the modified selector
voidaddNone(NoneSelector selector)
add a "None" selector entry on the selector list
voidaddNot(NotSelector selector)
add a "Not" selector entry on the selector list
voidaddOr(OrSelector selector)
add an "Or" selector entry on the selector list
voidaddPresent(PresentSelector selector)
add a present selector entry on the selector list
voidaddSelector(SelectSelector selector)
add a "Select" selector entry on the selector list
voidaddSize(SizeSelector selector)
add a selector size entry on the selector list
PatternSet.NameEntrycreateExclude()
add a name entry on the exclude list
PatternSet.NameEntrycreateExcludesFile()
add a name entry on the include files list
PatternSet.NameEntrycreateInclude()
add a name entry on the include list
PatternSet.NameEntrycreateIncludesFile()
add a name entry on the include files list
PatternSetcreatePatternSet()
add a set of patterns
voidexecute()
Delete the file(s).
protected voidremoveDir(File d)
Delete a directory
protected 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 true
voidsetCaseSensitive(boolean isCaseSensitive)
Sets case sensitivity of the file system
voidsetDefaultexcludes(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 continue
voidsetDir(File dir)
Set the directory from which files are to be deleted
voidsetExcludes(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.
voidsetFile(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(String includes)
Sets the set of include patterns.
voidsetIncludesfile(File includesfile)
Sets the name of the file containing the includes patterns.
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.
voidsetVerbose(boolean verbose)
If true, list all names of deleted files.

Field Detail

dir

protected File dir

file

protected File file

filesets

protected Vector filesets

includeEmpty

protected boolean includeEmpty

usedMatchingTask

protected boolean usedMatchingTask

Method Detail

add

public void add(FileSelector selector)
add an arbitrary selector

Parameters: selector the selector to be added

Since: Ant 1.6

addAnd

public void addAnd(AndSelector selector)
add an "And" selector entry on the selector list

Parameters: selector the selector to be added

addContains

public void addContains(ContainsSelector selector)
add a contains selector entry on the selector list

Parameters: selector the selector to be added

addContainsRegexp

public void addContainsRegexp(ContainsRegexpSelector selector)
add a regular expression selector entry on the selector list

Parameters: selector the selector to be added

addCustom

public void addCustom(ExtendSelector selector)
add an extended selector entry on the selector list

Parameters: selector the selector to be added

addDate

public void addDate(DateSelector selector)
add a selector date entry on the selector list

Parameters: selector the selector to be added

addDepend

public void addDepend(DependSelector selector)
add a depends selector entry on the selector list

Parameters: selector the selector to be added

addDepth

public void addDepth(DepthSelector selector)
add a depth selector entry on the selector list

Parameters: selector the selector to be added

addFilename

public void addFilename(FilenameSelector selector)
add a selector filename entry on the selector list

Parameters: selector the selector to be added

addFileset

public void addFileset(FileSet set)
Adds a set of files to be deleted.

Parameters: set the set of files to be deleted

addMajority

public void addMajority(MajoritySelector selector)
add a majority selector entry on the selector list

Parameters: selector the selector to be added

addModified

public void addModified(ModifiedSelector selector)
add the modified selector

Parameters: selector the selector to add

Since: ant 1.6

addNone

public void addNone(NoneSelector selector)
add a "None" selector entry on the selector list

Parameters: selector the selector to be added

addNot

public void addNot(NotSelector selector)
add a "Not" selector entry on the selector list

Parameters: selector the selector to be added

addOr

public void addOr(OrSelector selector)
add an "Or" selector entry on the selector list

Parameters: selector the selector to be added

addPresent

public void addPresent(PresentSelector selector)
add a present selector entry on the selector list

Parameters: selector the selector to be added

addSelector

public void addSelector(SelectSelector selector)
add a "Select" selector entry on the selector list

Parameters: selector the selector to be added

addSize

public void addSize(SizeSelector selector)
add a selector size entry on the selector list

Parameters: selector the selector to be added

createExclude

public PatternSet.NameEntry createExclude()
add a name entry on the exclude list

Returns: an NameEntry object to be configured

createExcludesFile

public PatternSet.NameEntry createExcludesFile()
add a name entry on the include files list

Returns: an NameEntry object to be configured

createInclude

public PatternSet.NameEntry createInclude()
add a name entry on the include list

Returns: a NameEntry object to be configured

createIncludesFile

public PatternSet.NameEntry createIncludesFile()
add a name entry on the include files list

Returns: an NameEntry object to be configured

createPatternSet

public PatternSet createPatternSet()
add a set of patterns

Returns: PatternSet object to be configured

execute

public void execute()
Delete the file(s).

Throws: BuildException if an error occurs

removeDir

protected void removeDir(File d)
Delete a directory

Parameters: d the directory to delete

removeFiles

protected void removeFiles(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 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

setCaseSensitive

public void setCaseSensitive(boolean isCaseSensitive)
Sets case sensitivity of the file system

Parameters: isCaseSensitive "true"|"on"|"yes" if file system is case sensitive, "false"|"off"|"no" when not.

setDefaultexcludes

public void setDefaultexcludes(boolean useDefaultExcludes)
Sets whether default exclusions should be used or not.

Parameters: useDefaultExcludes "true"|"on"|"yes" when default exclusions should be used, "false"|"off"|"no" when they shouldn't be used.

setDeleteOnExit

public 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

setDir

public void setDir(File dir)
Set the directory from which files are to be deleted

Parameters: dir the directory path.

setExcludes

public void setExcludes(String excludes)
Sets the set of exclude patterns. Patterns may be separated by a comma or a space.

Parameters: excludes the string containing the exclude patterns

setExcludesfile

public void setExcludesfile(File excludesfile)
Sets the name of the file containing the includes patterns.

Parameters: excludesfile A string containing the filename to fetch the include patterns from.

setFailOnError

public void setFailOnError(boolean failonerror)
If false, note errors but continue.

Parameters: failonerror true or false

setFile

public void setFile(File file)
Set the name of a single file to be removed.

Parameters: file the file to be deleted

setFollowSymlinks

public void setFollowSymlinks(boolean followSymlinks)
Sets whether or not symbolic links should be followed.

Parameters: followSymlinks whether or not symbolic links should be followed

setIncludeEmptyDirs

public void setIncludeEmptyDirs(boolean includeEmpty)
If true, delete empty directories.

Parameters: includeEmpty if true delete empty directories (only for filesets). Default is false.

setIncludes

public void setIncludes(String includes)
Sets the set of include patterns. Patterns may be separated by a comma or a space.

Parameters: includes the string containing the include patterns

setIncludesfile

public void setIncludesfile(File includesfile)
Sets the name of the file containing the includes patterns.

Parameters: includesfile A string containing the filename to fetch the include patterns from.

setQuiet

public 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"

setVerbose

public void setVerbose(boolean verbose)
If true, list all names of deleted files.

Parameters: verbose "true" or "on"

Copyright B) 2000-2007 Apache Software Foundation. All Rights Reserved.