ANT Tasks – Delete


Apache Ant Tasks – Delete



”;


Description

Delete task deletes a single file, a specified directory and all its files and subdirectories, or a set of files specified by one or more resource collections.

Properties












Sr.No Attributes & Description
1

File

The file to delete, specified as either the simple filename (if the file exists in the current base directory), a relative-path filename, or a full-path filename.

2

DIR

The directory to delete, including all its files and subdirectories.

3

Verbose

Whether to show the name of each deleted file.

4

Quiet

If the specified file or directory does not exist, do not display a diagnostic message.

5

Failonerror

Controls whether an error (such as a failure to delete a file) stops the build or is merely reported to the screen. Only relevant if quiet is false.

6

Includeemptydirs

Whether to delete empty directories when using filesets.

7

Deleteonexit

Indicates whether to use File#deleteOnExit() if there is a failure to delete a file. This causes the JVM to attempt to delete the file when the JVM process is terminating.

8

removeNotFollowedSymlinks

Whether symbolic links (not the files/directories they link to) should be removed if they haven”t been followed because followSymlinks was false or the maximum number of symbolic links was too big.

9

performGCOnFailedDelete

If Ant fails to delete a file or directory it will retry the operation once. If this flag is set to true it will perform a garbage collection before retrying the delete.

Example

Usage

Create build.xml with the following content −


<?xml version="1.0"?>
<project name="TutorialPoint" default="info">
   <target name="info">
      <delete file="text.txt" verbose="true"></delete>
   </target>
</project>

Output

Running Ant on the above build file produces the following output −


F:tutorialspointant>ant
Buildfile: F:tutorialspointantbuild.xml

info:
   [delete] Deleting: F:tutorialspointanttext.txt

BUILD SUCCESSFUL
Total time: 0 seconds

Advertisements

”;

Leave a Reply

Your email address will not be published. Required fields are marked *