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

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