1 | <!--
|
---|
2 | Licensed to the Apache Software Foundation (ASF) under one or more
|
---|
3 | contributor license agreements. See the NOTICE file distributed with
|
---|
4 | this work for additional information regarding copyright ownership.
|
---|
5 | The ASF licenses this file to You under the Apache License, Version 2.0
|
---|
6 | (the "License"); you may not use this file except in compliance with
|
---|
7 | the License. You may obtain a copy of the License at
|
---|
8 |
|
---|
9 | http://www.apache.org/licenses/LICENSE-2.0
|
---|
10 |
|
---|
11 | Unless required by applicable law or agreed to in writing, software
|
---|
12 | distributed under the License is distributed on an "AS IS" BASIS,
|
---|
13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
---|
14 | See the License for the specific language governing permissions and
|
---|
15 | limitations under the License.
|
---|
16 | -->
|
---|
17 | <html>
|
---|
18 |
|
---|
19 | <head>
|
---|
20 | <meta http-equiv="Content-Language" content="en-us">
|
---|
21 | <link rel="stylesheet" type="text/css" href="../stylesheets/style.css">
|
---|
22 | <title>Delete Task</title>
|
---|
23 | </head>
|
---|
24 |
|
---|
25 | <body>
|
---|
26 |
|
---|
27 | <h2><a name="delete">Delete</a></h2>
|
---|
28 | <h3>Description</h3>
|
---|
29 | <p>Deletes a single file, a specified directory and all its files and
|
---|
30 | subdirectories, or a set of files specified by one or more
|
---|
31 | <a href="../CoreTypes/resources.html#collection">resource collection</a>s.
|
---|
32 | The literal implication of <code><fileset></code> is that
|
---|
33 | directories are not included; however the removal of empty directories can
|
---|
34 | be triggered when using nested filesets by setting the
|
---|
35 | <code>includeEmptyDirs</code> attribute to <i>true</i>. Note that this
|
---|
36 | attribute is meaningless in the context of any of the various resource
|
---|
37 | collection types that <i>do</i> include directories, but that no attempt
|
---|
38 | will be made to delete non-empty directories in any case.</p>
|
---|
39 | <p>
|
---|
40 | If you use this task to delete temporary files created by editors
|
---|
41 | and it doesn't seem to work, read up on the
|
---|
42 | <a href="../dirtasks.html#defaultexcludes">default exclusion set</a>
|
---|
43 | in <strong>Directory-based Tasks</strong>, and see the
|
---|
44 | <code>defaultexcludes</code> attribute below.
|
---|
45 |
|
---|
46 | <h3>Parameters</h3>
|
---|
47 | <table border="1" cellpadding="2" cellspacing="0">
|
---|
48 | <tr>
|
---|
49 | <td valign="top"><b>Attribute</b></td>
|
---|
50 | <td valign="top"><b>Description</b></td>
|
---|
51 | <td align="center" valign="top"><b>Required</b></td>
|
---|
52 | </tr>
|
---|
53 | <tr>
|
---|
54 | <td valign="top">file</td>
|
---|
55 | <td valign="top">The file to delete, specified as either the simple
|
---|
56 | filename (if the file exists in the current base directory), a
|
---|
57 | relative-path filename, or a full-path filename.</td>
|
---|
58 | <td align="center" valign="middle" rowspan="2">At least one of the two,
|
---|
59 | unless nested resource collections are specified
|
---|
60 | </tr>
|
---|
61 | <tr>
|
---|
62 | <td valign="top">dir</td>
|
---|
63 | <td valign="top">The directory to delete, including all its files and
|
---|
64 | subdirectories.<br>
|
---|
65 | <b>Note:</b> <code>dir</code> is <em>not</em> used
|
---|
66 | to specify a directory name for <code>file</code>; <code>file</code>
|
---|
67 | and <code>dir</code> are independent of each other.<br>
|
---|
68 | <b>WARNING:</b> Do <b>not</b> set <code>dir</code> to
|
---|
69 | <code>"."</code>, <code>"${basedir}"</code>,
|
---|
70 | or the full-pathname equivalent unless you truly <em>intend</em> to
|
---|
71 | recursively remove the entire contents of the current base directory
|
---|
72 | (and the base directory itself, if different from the current working
|
---|
73 | directory).</td>
|
---|
74 | </tr>
|
---|
75 | <tr>
|
---|
76 | <td valign="top">verbose</td>
|
---|
77 | <td valign="top">Whether to show the name of each deleted file.</td>
|
---|
78 | <td align="center" valign="top">No, default "false"</i></td>
|
---|
79 | </tr>
|
---|
80 | <tr>
|
---|
81 | <td valign="top">quiet</td>
|
---|
82 | <td valign="top">If the specified file or directory does not exist,
|
---|
83 | do not display a diagnostic message (unless Ant
|
---|
84 | has been invoked with the <code>-verbose</code> or
|
---|
85 | <code>-debug</code> switches) or modify the exit status to
|
---|
86 | reflect an error.
|
---|
87 | When set to "true", if a file or directory cannot be deleted,
|
---|
88 | no error is reported. This setting emulates the
|
---|
89 | <code>-f</code> option to the Unix <em>rm</em> command.
|
---|
90 | Setting this to "true" implies setting
|
---|
91 | <code>failonerror</code> to "false".
|
---|
92 | </td>
|
---|
93 | <td align="center" valign="top">No, default "false"</td>
|
---|
94 | </tr>
|
---|
95 | <tr>
|
---|
96 | <td valign="top">failonerror</td>
|
---|
97 | <td valign="top">Controls whether an error (such as a failure to
|
---|
98 | delete a file) stops the build or is merely reported to the screen.
|
---|
99 | Only relevant if <code>quiet</code> is "false".</td>
|
---|
100 | <td align="center" valign="top">No, default "true"</td>
|
---|
101 | </tr>
|
---|
102 | <tr>
|
---|
103 | <td valign="top">includeemptydirs</td>
|
---|
104 | <td valign="top">Whether to delete empty directories
|
---|
105 | when using filesets.</td>
|
---|
106 | <td align="center" valign="top">No, default "false"</td>
|
---|
107 | </tr>
|
---|
108 | <tr>
|
---|
109 | <td valign="top">includes</td>
|
---|
110 | <td valign="top"><em>Deprecated.</em> Use resource collections.
|
---|
111 | Comma- or space-separated list of patterns of
|
---|
112 | files that must be deleted. All files are relative to the directory
|
---|
113 | specified in <code>dir</code>.</td>
|
---|
114 | <td valign="top" align="center">No</td>
|
---|
115 | </tr>
|
---|
116 | <tr>
|
---|
117 | <td valign="top">includesfile</td>
|
---|
118 | <td valign="top"><em>Deprecated.</em> Use resource collections.
|
---|
119 | The name of a file. Each line of
|
---|
120 | this file is taken to be an include pattern.</td>
|
---|
121 | <td valign="top" align="center">No</td>
|
---|
122 | </tr>
|
---|
123 | <tr>
|
---|
124 | <td valign="top">excludes</td>
|
---|
125 | <td valign="top"><em>Deprecated.</em> Use resource collections.
|
---|
126 | Comma- or space-separated list of patterns of
|
---|
127 | files that must be excluded from the deletion list.
|
---|
128 | All files are relative to the directory specified in <code>dir</code>.
|
---|
129 | No files (except default excludes) are excluded when omitted.</td>
|
---|
130 | <td valign="top" align="center">No</td>
|
---|
131 | </tr>
|
---|
132 | <tr>
|
---|
133 | <td valign="top">excludesfile</td>
|
---|
134 | <td valign="top"><em>Deprecated.</em> Use resource collections.
|
---|
135 | The name of a file. Each line of
|
---|
136 | this file is taken to be an exclude pattern</td>
|
---|
137 | <td valign="top" align="center">No</td>
|
---|
138 | </tr>
|
---|
139 | <tr>
|
---|
140 | <td valign="top">defaultexcludes</td>
|
---|
141 | <td valign="top"><em>Deprecated.</em> Use resource collections.
|
---|
142 | Whether to use <a href="../dirtasks.html#defaultexcludes">
|
---|
143 | default excludes.</a></td>
|
---|
144 | <td align="center" valign="top">No, default "true"</td>
|
---|
145 | </tr>
|
---|
146 | <tr>
|
---|
147 | <td valign="top">deleteonexit</td>
|
---|
148 | <td valign="top">
|
---|
149 | Indicates whether to use File#deleteOnExit() if there is a
|
---|
150 | failure to delete a file, this causes the jvm to attempt
|
---|
151 | to delete the file when the jvm process is terminating.
|
---|
152 | <em>Since Ant 1.6.2</em></td>
|
---|
153 | <td align="center" valign="top">No, default "false"</td>
|
---|
154 | </tr>
|
---|
155 | </table>
|
---|
156 |
|
---|
157 | <h3>Examples</h3>
|
---|
158 | <pre> <delete file="/lib/ant.jar"/></pre>
|
---|
159 | <p>deletes the file <code>/lib/ant.jar</code>.</p>
|
---|
160 | <pre> <delete dir="lib"/></pre>
|
---|
161 | <p>deletes the <code>lib</code> directory, including all files
|
---|
162 | and subdirectories of <code>lib</code>.</p>
|
---|
163 |
|
---|
164 | <pre> <delete>
|
---|
165 | <fileset dir="." includes="**/*.bak"/>
|
---|
166 | </delete>
|
---|
167 | </pre>
|
---|
168 | <p>deletes all files with the extension <code>.bak</code> from the current directory
|
---|
169 | and any subdirectories.</p>
|
---|
170 |
|
---|
171 | <pre> <delete includeEmptyDirs="true">
|
---|
172 | <fileset dir="build"/>
|
---|
173 | </delete>
|
---|
174 | </pre>
|
---|
175 | <p>deletes all files and subdirectories of <code>build</code>, including
|
---|
176 | <code>build</code> itself.</p>
|
---|
177 |
|
---|
178 | <pre> <delete includeemptydirs="true">
|
---|
179 | <fileset dir="build" includes="**/*"/>
|
---|
180 | </delete>
|
---|
181 | </pre>
|
---|
182 | <p>deletes all files and subdirectories of <code>build</code>, without
|
---|
183 | <code>build</code> itself.</p>
|
---|
184 |
|
---|
185 | <pre> <delete defaultexcludes="false">
|
---|
186 | <fileset dir="src" includes="**/.svn"/>
|
---|
187 | </delete>
|
---|
188 | </pre>
|
---|
189 | <p>deletes the subversion metadata directories under <code>src</code>. Because <code>.svn</code>
|
---|
190 | is on of the <a href="../dirtasks.html#defaultexcludes">default excludes</a> you have to use the
|
---|
191 | <code>defaultexcludes</code> flag, otherwise Ant wont delete these directories and the files in it.</p>
|
---|
192 |
|
---|
193 |
|
---|
194 |
|
---|
195 | </body>
|
---|
196 | </html>
|
---|