Delete

Description

Deletes either a single file, all files in a specified directory and its sub-directories, or a set of files specified by one or more FileSets. When specifying a set of files, empty directories are not removed by default. To remove empty directories, use the includeEmptyDirs atribute.

Parameters

Setting this to true, implies setting failonerror to false.
Attribute Description Required
file The file to delete. at least one of the two
dir The directory to delete files from.
verbose Show name of each deleted file ("true"/"false"). Default is "false" when omitted. No
quiet If the file does not exist, do not display a diagnostic message or modify the exit status to reflect an error (unless Ant has been invoked with the -verbose or -debug switches). 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. ("true"/"false"). Default is "false" meaning things are "noisy".No
failonerror This flag (which is only of relevance if 'quiet' is false), controls whether an error -such as a failure to delete a file- stops the build task, or is merely reported to the screen. The default is "true" No
includeEmptyDirs Set to "true" to delete empty directories when using filesets. Default is "false". No
includes Deprecated. Comma separated list of patterns of files that must be deleted. All files are in the current directory and any sub-directories are deleted when omitted. No
includesfile Deprecated. The name of a file. Each line of this file is taken to be an include pattern No
excludes Deprecated. Comma separated list of patterns of files that must be excluded from the deletion list. No files (except default excludes) are excluded when omitted. No
excludesfile Deprecated. The name of a file. Each line of this file is taken to be an exclude pattern No
defaultexcludes Deprecated. Indicates whether default excludes should be used or not ("yes"/"no"). Default excludes are used when omitted. No

Examples

  <delete file="/lib/ant.jar"/>

deletes the file /lib/ant.jar.

  <delete dir="lib"/>

deletes the lib directory, including all files and subdirectories of lib.

  <delete>
    <fileset dir="." includes="**/*.bak"/>
  </delete>

deletes all files with the extension ".bak" from the current directory and any sub-directories.

  <delete includeEmptyDirs="true" >
    <fileset dir="build" />
  </delete>

deletes all files and subdirectories of build, but not build itself.


Copyright © 2000,2001 Apache Software Foundation. All rights Reserved.