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

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