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 6.9 KiB

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