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

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