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.2 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  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. Whether a
  34. directory is empty or not is decided by looking into the filesystem -
  35. include or exclude patterns don't apply here.</p>
  36. <p>
  37. If you use this task to delete temporary files created by editors
  38. and it doesn't seem to work, read up on the
  39. <a href="../dirtasks.html#defaultexcludes">default exclusion set</a>
  40. in <strong>Directory-based Tasks</strong>, and see the
  41. <code>defaultexcludes</code> attribute below.
  42. <h3>Parameters</h3>
  43. <table border="1" cellpadding="2" cellspacing="0">
  44. <tr>
  45. <td valign="top"><b>Attribute</b></td>
  46. <td valign="top"><b>Description</b></td>
  47. <td align="center" valign="top"><b>Required</b></td>
  48. </tr>
  49. <tr>
  50. <td valign="top">file</td>
  51. <td valign="top">The file to delete, specified as either the simple
  52. filename (if the file exists in the current base directory), a
  53. relative-path filename, or a full-path filename.</td>
  54. <td align="center" valign="middle" rowspan="2">At least one of the two,
  55. unless nested resource collections are specified
  56. </tr>
  57. <tr>
  58. <td valign="top">dir</td>
  59. <td valign="top">The directory to delete, including all its files and
  60. subdirectories.<br>
  61. <b>Note:</b> <code>dir</code> is <em>not</em> used
  62. to specify a directory name for <code>file</code>; <code>file</code>
  63. and <code>dir</code> are independent of each other.<br>
  64. <b>WARNING:</b> Do <b>not</b> set <code>dir</code> to
  65. <code>&quot;.&quot;</code>, <code>&quot;${basedir}&quot;</code>,
  66. or the full-pathname equivalent unless you truly <em>intend</em> to
  67. recursively remove the entire contents of the current base directory
  68. (and the base directory itself, if different from the current working
  69. directory).</td>
  70. </tr>
  71. <tr>
  72. <td valign="top">verbose</td>
  73. <td valign="top">Whether to show the name of each deleted file.</td>
  74. <td align="center" valign="top">No, default &quot;false&quot;</i></td>
  75. </tr>
  76. <tr>
  77. <td valign="top">quiet</td>
  78. <td valign="top">If the specified file or directory does not exist,
  79. do not display a diagnostic message (unless Ant
  80. has been invoked with the <code>-verbose</code> or
  81. <code>-debug</code> switches) or modify the exit status to
  82. reflect an error.
  83. When set to &quot;true&quot;, if a file or directory cannot be deleted,
  84. no error is reported. This setting emulates the
  85. <code>-f</code> option to the Unix <em>rm</em> command.
  86. Setting this to &quot;true&quot; implies setting
  87. <code>failonerror</code> to &quot;false&quot;.
  88. </td>
  89. <td align="center" valign="top">No, default &quot;false&quot;</td>
  90. </tr>
  91. <tr>
  92. <td valign="top">failonerror</td>
  93. <td valign="top">Controls whether an error (such as a failure to
  94. delete a file) stops the build or is merely reported to the screen.
  95. Only relevant if <code>quiet</code> is &quot;false&quot;.</td>
  96. <td align="center" valign="top">No, default &quot;true&quot;</td>
  97. </tr>
  98. <tr>
  99. <td valign="top">includeemptydirs</td>
  100. <td valign="top">Whether to delete empty directories
  101. when using filesets.</td>
  102. <td align="center" valign="top">No, default &quot;false&quot;</td>
  103. </tr>
  104. <tr>
  105. <td valign="top">includes</td>
  106. <td valign="top"><em>Deprecated.</em> Use resource collections.
  107. Comma- or space-separated list of patterns of
  108. files that must be deleted. All files are relative to the directory
  109. specified in <code>dir</code>.</td>
  110. <td valign="top" align="center">No</td>
  111. </tr>
  112. <tr>
  113. <td valign="top">includesfile</td>
  114. <td valign="top"><em>Deprecated.</em> Use resource collections.
  115. The name of a file. Each line of
  116. this file is taken to be an include pattern.</td>
  117. <td valign="top" align="center">No</td>
  118. </tr>
  119. <tr>
  120. <td valign="top">excludes</td>
  121. <td valign="top"><em>Deprecated.</em> Use resource collections.
  122. Comma- or space-separated list of patterns of
  123. files that must be excluded from the deletion list.
  124. All files are relative to the directory specified in <code>dir</code>.
  125. No files (except default excludes) are excluded when omitted.</td>
  126. <td valign="top" align="center">No</td>
  127. </tr>
  128. <tr>
  129. <td valign="top">excludesfile</td>
  130. <td valign="top"><em>Deprecated.</em> Use resource collections.
  131. The name of a file. Each line of
  132. this file is taken to be an exclude pattern</td>
  133. <td valign="top" align="center">No</td>
  134. </tr>
  135. <tr>
  136. <td valign="top">defaultexcludes</td>
  137. <td valign="top"><em>Deprecated.</em> Use resource collections.
  138. Whether to use <a href="../dirtasks.html#defaultexcludes">
  139. default excludes.</a></td>
  140. <td align="center" valign="top">No, default &quot;true&quot;</td>
  141. </tr>
  142. <tr>
  143. <td valign="top">deleteonexit</td>
  144. <td valign="top">
  145. Indicates whether to use File#deleteOnExit() if there is a
  146. failure to delete a file, this causes the jvm to attempt
  147. to delete the file when the jvm process is terminating.
  148. <em>Since Ant 1.6.2</em></td>
  149. <td align="center" valign="top">No, default &quot;false&quot;</td>
  150. </tr>
  151. </table>
  152. <h3>Examples</h3>
  153. <pre> &lt;delete file=&quot;/lib/ant.jar&quot;/&gt;</pre>
  154. <p>deletes the file <code>/lib/ant.jar</code>.</p>
  155. <pre> &lt;delete dir=&quot;lib&quot;/&gt;</pre>
  156. <p>deletes the <code>lib</code> directory, including all files
  157. and subdirectories of <code>lib</code>.</p>
  158. <pre> &lt;delete&gt;
  159. &lt;fileset dir=&quot;.&quot; includes=&quot;**/*.bak&quot;/&gt;
  160. &lt;/delete&gt;
  161. </pre>
  162. <p>deletes all files with the extension <code>.bak</code> from the current directory
  163. and any subdirectories.</p>
  164. <pre> &lt;delete includeEmptyDirs=&quot;true&quot;&gt;
  165. &lt;fileset dir=&quot;build&quot;/&gt;
  166. &lt;/delete&gt;
  167. </pre>
  168. <p>deletes all files and subdirectories of <code>build</code>, including
  169. <code>build</code> itself.</p>
  170. <pre> &lt;delete includeemptydirs=&quot;true&quot;&gt;
  171. &lt;fileset dir=&quot;build&quot; includes=&quot;**/*&quot;/&gt;
  172. &lt;/delete&gt;
  173. </pre>
  174. <p>deletes all files and subdirectories of <code>build</code>, without
  175. <code>build</code> itself.</p>
  176. <pre> &lt;delete includeemptydirs=&quot;true&quot;&gt;
  177. &lt;fileset dir=&quot;src&quot; includes=&quot;**/.svn&quot; defaultexcludes=&quot;false&quot;/&gt;
  178. &lt;/delete&gt;
  179. </pre>
  180. <p>deletes the subversion metadata directories under <code>src</code>. Because <code>.svn</code>
  181. is on of the <a href="../dirtasks.html#defaultexcludes">default excludes</a> you have to use the
  182. <code>defaultexcludes</code> flag, otherwise Ant wont delete these directories and the files in it.</p>
  183. </body>
  184. </html>