You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

delete.html 8.0 KiB

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