2006-09-11 04:19:00 +00:00
|
|
|
<!--
|
|
|
|
Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
contributor license agreements. See the NOTICE file distributed with
|
|
|
|
this work for additional information regarding copyright ownership.
|
|
|
|
The ASF licenses this file to You under the Apache License, Version 2.0
|
|
|
|
(the "License"); you may not use this file except in compliance with
|
|
|
|
the License. You may obtain a copy of the License at
|
|
|
|
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
See the License for the specific language governing permissions and
|
|
|
|
limitations under the License.
|
|
|
|
-->
|
2001-02-13 12:32:01 +00:00
|
|
|
<html>
|
|
|
|
|
|
|
|
<head>
|
|
|
|
<meta http-equiv="Content-Language" content="en-us">
|
2005-04-29 18:58:16 +00:00
|
|
|
<link rel="stylesheet" type="text/css" href="../stylesheets/style.css">
|
2002-02-03 22:00:42 +00:00
|
|
|
<title>Delete Task</title>
|
2001-02-13 12:32:01 +00:00
|
|
|
</head>
|
|
|
|
|
|
|
|
<body>
|
|
|
|
|
|
|
|
<h2><a name="delete">Delete</a></h2>
|
|
|
|
<h3>Description</h3>
|
2002-02-05 20:21:59 +00:00
|
|
|
<p>Deletes a single file, a specified directory and all its files and
|
|
|
|
subdirectories, or a set of files specified by one or more
|
2005-09-14 21:24:08 +00:00
|
|
|
<a href="../CoreTypes/resources.html#collection">resource collection</a>s.
|
|
|
|
The literal implication of <code><fileset></code> is that
|
|
|
|
directories are not included; however the removal of empty directories can
|
|
|
|
be triggered when using nested filesets by setting the
|
|
|
|
<code>includeEmptyDirs</code> attribute to <i>true</i>. Note that this
|
|
|
|
attribute is meaningless in the context of any of the various resource
|
|
|
|
collection types that <i>do</i> include directories, but that no attempt
|
|
|
|
will be made to delete non-empty directories in any case.</p>
|
2002-02-28 18:45:15 +00:00
|
|
|
<p>
|
2002-03-22 18:55:29 +00:00
|
|
|
If you use this task to delete temporary files created by editors
|
2006-07-06 05:57:55 +00:00
|
|
|
and it doesn't seem to work, read up on the
|
2002-03-22 18:55:29 +00:00
|
|
|
<a href="../dirtasks.html#defaultexcludes">default exclusion set</a>
|
|
|
|
in <strong>Directory-based Tasks</strong>, and see the
|
|
|
|
<code>defaultexcludes</code> attribute below.
|
2006-07-06 05:57:55 +00:00
|
|
|
|
2001-02-13 12:32:01 +00:00
|
|
|
<h3>Parameters</h3>
|
|
|
|
<table border="1" cellpadding="2" cellspacing="0">
|
|
|
|
<tr>
|
|
|
|
<td valign="top"><b>Attribute</b></td>
|
|
|
|
<td valign="top"><b>Description</b></td>
|
|
|
|
<td align="center" valign="top"><b>Required</b></td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td valign="top">file</td>
|
2002-02-13 04:35:57 +00:00
|
|
|
<td valign="top">The file to delete, specified as either the simple
|
|
|
|
filename (if the file exists in the current base directory), a
|
|
|
|
relative-path filename, or a full-path filename.</td>
|
|
|
|
<td align="center" valign="middle" rowspan="2">At least one of the two,
|
2005-09-14 21:24:08 +00:00
|
|
|
unless nested resource collections are specified
|
2001-02-13 12:32:01 +00:00
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td valign="top">dir</td>
|
2002-02-13 03:51:58 +00:00
|
|
|
<td valign="top">The directory to delete, including all its files and
|
2002-02-13 04:35:57 +00:00
|
|
|
subdirectories.<br>
|
|
|
|
<b>Note:</b> <code>dir</code> is <em>not</em> used
|
|
|
|
to specify a directory name for <code>file</code>; <code>file</code>
|
|
|
|
and <code>dir</code> are independent of each other.<br>
|
|
|
|
<b>WARNING:</b> Do <b>not</b> set <code>dir</code> to
|
2002-02-13 03:51:58 +00:00
|
|
|
<code>"."</code>, <code>"${basedir}"</code>,
|
|
|
|
or the full-pathname equivalent unless you truly <em>intend</em> to
|
|
|
|
recursively remove the entire contents of the current base directory
|
|
|
|
(and the base directory itself, if different from the current working
|
|
|
|
directory).</td>
|
2001-02-13 12:32:01 +00:00
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td valign="top">verbose</td>
|
2004-11-03 21:50:26 +00:00
|
|
|
<td valign="top">Whether to show the name of each deleted file.</td>
|
|
|
|
<td align="center" valign="top">No, default "false"</i></td>
|
2001-02-13 12:32:01 +00:00
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td valign="top">quiet</td>
|
2002-02-13 04:35:57 +00:00
|
|
|
<td valign="top">If the specified file or directory does not exist,
|
|
|
|
do not display a diagnostic message (unless Ant
|
2005-04-29 18:58:16 +00:00
|
|
|
has been invoked with the <code>-verbose</code> or
|
|
|
|
<code>-debug</code> switches) or modify the exit status to
|
2002-02-05 20:21:59 +00:00
|
|
|
reflect an error.
|
|
|
|
When set to "true", if a file or directory cannot be deleted,
|
2006-07-06 05:57:55 +00:00
|
|
|
no error is reported. This setting emulates the
|
2002-02-05 20:21:59 +00:00
|
|
|
<code>-f</code> option to the Unix <em>rm</em> command.
|
|
|
|
Setting this to "true" implies setting
|
|
|
|
<code>failonerror</code> to "false".
|
|
|
|
</td>
|
2004-11-03 21:50:26 +00:00
|
|
|
<td align="center" valign="top">No, default "false"</td>
|
2001-02-13 12:32:01 +00:00
|
|
|
</tr>
|
2001-07-27 08:24:59 +00:00
|
|
|
<tr>
|
|
|
|
<td valign="top">failonerror</td>
|
2004-11-03 21:50:26 +00:00
|
|
|
<td valign="top">Controls whether an error (such as a failure to
|
|
|
|
delete a file) stops the build or is merely reported to the screen.
|
|
|
|
Only relevant if <code>quiet</code> is "false".</td>
|
|
|
|
<td align="center" valign="top">No, default "true"</td>
|
|
|
|
</tr>
|
2001-02-13 12:32:01 +00:00
|
|
|
<tr>
|
2004-11-03 21:50:26 +00:00
|
|
|
<td valign="top">includeemptydirs</td>
|
|
|
|
<td valign="top">Whether to delete empty directories
|
|
|
|
when using filesets.</td>
|
|
|
|
<td align="center" valign="top">No, default "false"</td>
|
2001-02-13 12:32:01 +00:00
|
|
|
</tr>
|
2002-02-08 21:07:21 +00:00
|
|
|
<tr>
|
|
|
|
<td valign="top">includes</td>
|
2005-09-14 21:24:08 +00:00
|
|
|
<td valign="top"><em>Deprecated.</em> Use resource collections.
|
2002-06-22 23:38:38 +00:00
|
|
|
Comma- or space-separated list of patterns of
|
2002-02-08 21:07:21 +00:00
|
|
|
files that must be deleted. All files are relative to the directory
|
2004-11-03 21:50:26 +00:00
|
|
|
specified in <code>dir</code>.</td>
|
2002-02-08 21:07:21 +00:00
|
|
|
<td valign="top" align="center">No</td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td valign="top">includesfile</td>
|
2005-09-14 21:24:08 +00:00
|
|
|
<td valign="top"><em>Deprecated.</em> Use resource collections.
|
2002-02-08 21:07:21 +00:00
|
|
|
The name of a file. Each line of
|
2004-11-03 21:50:26 +00:00
|
|
|
this file is taken to be an include pattern.</td>
|
2002-02-08 21:07:21 +00:00
|
|
|
<td valign="top" align="center">No</td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td valign="top">excludes</td>
|
2005-09-14 21:24:08 +00:00
|
|
|
<td valign="top"><em>Deprecated.</em> Use resource collections.
|
2002-06-22 23:38:38 +00:00
|
|
|
Comma- or space-separated list of patterns of
|
2002-02-08 21:07:21 +00:00
|
|
|
files that must be excluded from the deletion list.
|
|
|
|
All files are relative to the directory specified in <code>dir</code>.
|
|
|
|
No files (except default excludes) are excluded when omitted.</td>
|
|
|
|
<td valign="top" align="center">No</td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td valign="top">excludesfile</td>
|
2005-09-14 21:24:08 +00:00
|
|
|
<td valign="top"><em>Deprecated.</em> Use resource collections.
|
2002-02-08 21:07:21 +00:00
|
|
|
The name of a file. Each line of
|
|
|
|
this file is taken to be an exclude pattern</td>
|
|
|
|
<td valign="top" align="center">No</td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td valign="top">defaultexcludes</td>
|
2005-09-14 21:24:08 +00:00
|
|
|
<td valign="top"><em>Deprecated.</em> Use resource collections.
|
2004-11-03 21:50:26 +00:00
|
|
|
Whether to use <a href="../dirtasks.html#defaultexcludes">
|
|
|
|
default excludes.</a></td>
|
|
|
|
<td align="center" valign="top">No, default "true"</td>
|
2002-02-08 21:07:21 +00:00
|
|
|
</tr>
|
2004-06-08 16:19:27 +00:00
|
|
|
<tr>
|
|
|
|
<td valign="top">deleteonexit</td>
|
|
|
|
<td valign="top">
|
|
|
|
Indicates whether to use File#deleteOnExit() if there is a
|
|
|
|
failure to delete a file, this causes the jvm to attempt
|
|
|
|
to delete the file when the jvm process is terminating.
|
2004-11-03 21:50:26 +00:00
|
|
|
<em>Since Ant 1.6.2</em></td>
|
2005-09-14 21:24:08 +00:00
|
|
|
<td align="center" valign="top">No, default "false"</td>
|
2004-06-08 16:19:27 +00:00
|
|
|
</tr>
|
2001-02-13 12:32:01 +00:00
|
|
|
</table>
|
2006-07-06 05:57:55 +00:00
|
|
|
|
2001-02-13 12:32:01 +00:00
|
|
|
<h3>Examples</h3>
|
|
|
|
<pre> <delete file="/lib/ant.jar"/></pre>
|
|
|
|
<p>deletes the file <code>/lib/ant.jar</code>.</p>
|
|
|
|
<pre> <delete dir="lib"/></pre>
|
2006-07-06 05:57:55 +00:00
|
|
|
<p>deletes the <code>lib</code> directory, including all files
|
2001-02-13 12:32:01 +00:00
|
|
|
and subdirectories of <code>lib</code>.</p>
|
2006-07-06 05:57:55 +00:00
|
|
|
|
2001-02-13 12:32:01 +00:00
|
|
|
<pre> <delete>
|
|
|
|
<fileset dir="." includes="**/*.bak"/>
|
|
|
|
</delete>
|
|
|
|
</pre>
|
2006-07-06 05:57:55 +00:00
|
|
|
<p>deletes all files with the extension <code>.bak</code> from the current directory
|
2002-02-05 20:21:59 +00:00
|
|
|
and any subdirectories.</p>
|
2006-07-06 05:57:55 +00:00
|
|
|
|
2002-09-04 11:05:19 +00:00
|
|
|
<pre> <delete includeEmptyDirs="true">
|
|
|
|
<fileset dir="build"/>
|
2001-02-13 12:32:01 +00:00
|
|
|
</delete>
|
|
|
|
</pre>
|
2001-08-30 13:23:14 +00:00
|
|
|
<p>deletes all files and subdirectories of <code>build</code>, including
|
2001-02-13 12:32:01 +00:00
|
|
|
<code>build</code> itself.</p>
|
2006-07-06 05:57:55 +00:00
|
|
|
|
2004-06-22 14:39:36 +00:00
|
|
|
<pre> <delete includeemptydirs="true">
|
|
|
|
<fileset dir="build" includes="**/*"/>
|
|
|
|
</delete>
|
|
|
|
</pre>
|
|
|
|
<p>deletes all files and subdirectories of <code>build</code>, without
|
|
|
|
<code>build</code> itself.</p>
|
2006-07-06 05:57:55 +00:00
|
|
|
|
|
|
|
<pre> <delete defaultexcludes="false">
|
|
|
|
<fileset dir="src" includes="**/.svn"/>
|
|
|
|
</delete>
|
|
|
|
</pre>
|
|
|
|
<p>deletes the subversion metadata directories under <code>src</code>. Because <code>.svn</code>
|
|
|
|
is on of the <a href="../dirtasks.html#defaultexcludes">default excludes</a> you have to use the
|
|
|
|
<code>defaultexcludes</code> flag, otherwise Ant wont delete these directories and the files in it.</p>
|
|
|
|
|
2006-09-11 20:22:51 +00:00
|
|
|
|
2001-02-13 12:32:01 +00:00
|
|
|
|
|
|
|
</body>
|
|
|
|
</html>
|