1 | <html>
|
---|
2 |
|
---|
3 | <head>
|
---|
4 | <meta http-equiv="Content-Language" content="en-us">
|
---|
5 | <title>Delete Task</title>
|
---|
6 | <link rel="stylesheet" type="text/css" href="../stylesheets/antmanual.css">
|
---|
7 | </head>
|
---|
8 |
|
---|
9 | <body>
|
---|
10 |
|
---|
11 | <h2><a name="delete">Delete</a></h2>
|
---|
12 | <h3>Description</h3>
|
---|
13 | <p>Deletes a single file, a specified directory and all its files and
|
---|
14 | subdirectories, or a set of files specified by one or more
|
---|
15 | <a href="../CoreTypes/fileset.html">FileSet</a>s.
|
---|
16 | When specifying a set of files, empty directories are <i>not</i> removed by
|
---|
17 | default.
|
---|
18 | To remove empty directories, use the <code>includeEmptyDirs</code> attribute.
|
---|
19 | </p>
|
---|
20 | <p>
|
---|
21 | If you use this task to delete temporary files created by editors
|
---|
22 | and it doesn't seem to work, read up on the
|
---|
23 | <a href="../dirtasks.html#defaultexcludes">default exclusion set</a>
|
---|
24 | in <strong>Directory-based Tasks</strong>, and see the
|
---|
25 | <code>defaultexcludes</code> attribute below.
|
---|
26 |
|
---|
27 | <h3>Parameters</h3>
|
---|
28 | <table border="1" cellpadding="2" cellspacing="0">
|
---|
29 | <tr>
|
---|
30 | <td valign="top"><b>Attribute</b></td>
|
---|
31 | <td valign="top"><b>Description</b></td>
|
---|
32 | <td align="center" valign="top"><b>Required</b></td>
|
---|
33 | </tr>
|
---|
34 | <tr>
|
---|
35 | <td valign="top">file</td>
|
---|
36 | <td valign="top">The file to delete, specified as either the simple
|
---|
37 | filename (if the file exists in the current base directory), a
|
---|
38 | relative-path filename, or a full-path filename.</td>
|
---|
39 | <td align="center" valign="middle" rowspan="2">At least one of the two,
|
---|
40 | unless a <code><fileset></code> is specified.</td>
|
---|
41 | </tr>
|
---|
42 | <tr>
|
---|
43 | <td valign="top">dir</td>
|
---|
44 | <td valign="top">The directory to delete, including all its files and
|
---|
45 | subdirectories.<br>
|
---|
46 | <b>Note:</b> <code>dir</code> is <em>not</em> used
|
---|
47 | to specify a directory name for <code>file</code>; <code>file</code>
|
---|
48 | and <code>dir</code> are independent of each other.<br>
|
---|
49 | <b>WARNING:</b> Do <b>not</b> set <code>dir</code> to
|
---|
50 | <code>"."</code>, <code>"${basedir}"</code>,
|
---|
51 | or the full-pathname equivalent unless you truly <em>intend</em> to
|
---|
52 | recursively remove the entire contents of the current base directory
|
---|
53 | (and the base directory itself, if different from the current working
|
---|
54 | directory).</td>
|
---|
55 | </tr>
|
---|
56 | <tr>
|
---|
57 | <td valign="top">verbose</td>
|
---|
58 | <td valign="top">Whether to show the name of each deleted file.</td>
|
---|
59 | <td align="center" valign="top">No, default "false"</i></td>
|
---|
60 | </tr>
|
---|
61 | <tr>
|
---|
62 | <td valign="top">quiet</td>
|
---|
63 | <td valign="top">If the specified file or directory does not exist,
|
---|
64 | do not display a diagnostic message (unless Ant
|
---|
65 | has been invoked with the <code>‑verbose</code> or
|
---|
66 | <code>‑debug</code> switches) or modify the exit status to
|
---|
67 | reflect an error.
|
---|
68 | When set to "true", if a file or directory cannot be deleted,
|
---|
69 | no error is reported. This setting emulates the
|
---|
70 | <code>-f</code> option to the Unix <em>rm</em> command.
|
---|
71 | Setting this to "true" implies setting
|
---|
72 | <code>failonerror</code> to "false".
|
---|
73 | </td>
|
---|
74 | <td align="center" valign="top">No, default "false"</td>
|
---|
75 | </tr>
|
---|
76 | <tr>
|
---|
77 | <td valign="top">failonerror</td>
|
---|
78 | <td valign="top">Controls whether an error (such as a failure to
|
---|
79 | delete a file) stops the build or is merely reported to the screen.
|
---|
80 | Only relevant if <code>quiet</code> is "false".</td>
|
---|
81 | <td align="center" valign="top">No, default "true"</td>
|
---|
82 | </tr>
|
---|
83 | <tr>
|
---|
84 | <td valign="top">includeemptydirs</td>
|
---|
85 | <td valign="top">Whether to delete empty directories
|
---|
86 | when using filesets.</td>
|
---|
87 | <td align="center" valign="top">No, default "false"</td>
|
---|
88 | </tr>
|
---|
89 | <tr>
|
---|
90 | <td valign="top">includes</td>
|
---|
91 | <td valign="top"><em>Deprecated.</em> Use <code><fileset></code>.
|
---|
92 | Comma- or space-separated list of patterns of
|
---|
93 | files that must be deleted. All files are relative to the directory
|
---|
94 | specified in <code>dir</code>.</td>
|
---|
95 | <td valign="top" align="center">No</td>
|
---|
96 | </tr>
|
---|
97 | <tr>
|
---|
98 | <td valign="top">includesfile</td>
|
---|
99 | <td valign="top"><em>Deprecated.</em> Use <code><fileset></code>.
|
---|
100 | The name of a file. Each line of
|
---|
101 | this file is taken to be an include pattern.</td>
|
---|
102 | <td valign="top" align="center">No</td>
|
---|
103 | </tr>
|
---|
104 | <tr>
|
---|
105 | <td valign="top">excludes</td>
|
---|
106 | <td valign="top"><em>Deprecated.</em> Use <code><fileset></code>.
|
---|
107 | Comma- or space-separated list of patterns of
|
---|
108 | files that must be excluded from the deletion list.
|
---|
109 | All files are relative to the directory specified in <code>dir</code>.
|
---|
110 | No files (except default excludes) are excluded when omitted.</td>
|
---|
111 | <td valign="top" align="center">No</td>
|
---|
112 | </tr>
|
---|
113 | <tr>
|
---|
114 | <td valign="top">excludesfile</td>
|
---|
115 | <td valign="top"><em>Deprecated.</em> Use <code><fileset></code>.
|
---|
116 | The name of a file. Each line of
|
---|
117 | this file is taken to be an exclude pattern</td>
|
---|
118 | <td valign="top" align="center">No</td>
|
---|
119 | </tr>
|
---|
120 | <tr>
|
---|
121 | <td valign="top">defaultexcludes</td>
|
---|
122 | <td valign="top"><em>Deprecated.</em> Use <code><fileset></code>.
|
---|
123 | Whether to use <a href="../dirtasks.html#defaultexcludes">
|
---|
124 | default excludes.</a></td>
|
---|
125 | <td align="center" valign="top">No, default "true"</td>
|
---|
126 | </tr>
|
---|
127 | <tr>
|
---|
128 | <td valign="top">deleteonexit</td>
|
---|
129 | <td valign="top">
|
---|
130 | Indicates whether to use File#deleteOnExit() if there is a
|
---|
131 | failure to delete a file, this causes the jvm to attempt
|
---|
132 | to delete the file when the jvm process is terminating.
|
---|
133 | <em>Since Ant 1.6.2</em></td>
|
---|
134 | <td align="center" valign="top">No, default "false".</td>
|
---|
135 | </tr>
|
---|
136 | </table>
|
---|
137 | <h3>Examples</h3>
|
---|
138 | <pre> <delete file="/lib/ant.jar"/></pre>
|
---|
139 | <p>deletes the file <code>/lib/ant.jar</code>.</p>
|
---|
140 | <pre> <delete dir="lib"/></pre>
|
---|
141 | <p>deletes the <code>lib</code> directory, including all files
|
---|
142 | and subdirectories of <code>lib</code>.</p>
|
---|
143 | <pre> <delete>
|
---|
144 | <fileset dir="." includes="**/*.bak"/>
|
---|
145 | </delete>
|
---|
146 | </pre>
|
---|
147 | <p>deletes all files with the extension <code>.bak</code> from the current directory
|
---|
148 | and any subdirectories.</p>
|
---|
149 | <pre> <delete includeEmptyDirs="true">
|
---|
150 | <fileset dir="build"/>
|
---|
151 | </delete>
|
---|
152 | </pre>
|
---|
153 | <p>deletes all files and subdirectories of <code>build</code>, including
|
---|
154 | <code>build</code> itself.</p>
|
---|
155 | <pre> <delete includeemptydirs="true">
|
---|
156 | <fileset dir="build" includes="**/*"/>
|
---|
157 | </delete>
|
---|
158 | </pre>
|
---|
159 | <p>deletes all files and subdirectories of <code>build</code>, without
|
---|
160 | <code>build</code> itself.</p>
|
---|
161 | <hr><p align="center">Copyright © 2000-2002,2004 The Apache Software Foundation.
|
---|
162 | All rights Reserved.</p>
|
---|
163 |
|
---|
164 | </body>
|
---|
165 | </html>
|
---|
166 |
|
---|