ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Tom Dimock <>
Subject deletefiles
Date Mon, 12 Jun 2000 17:26:55 GMT
In my use of Ant, I have frequently had the need to delete a set of files
based on some wildcard specifications.  To do this, I have written a new
task definition for "deletefiles".  I have included the documentation
below.  Would there be interest in this as an addition to the Ant standard
tasks?  I'd be glad to contribute it.

<h2><a name="deletefiles">Deletefiles</a></h2>
<p>Deletes all files from the specified directory and its sub-directories.</p>
<p>It is possible to refine the set of files that are being deleted. This
can be
done with the <i>includes</i>, <i>excludes</i> and <i>defaultexcludes</i>
attributes. With the <i>includes</i> attribute you specify the files you
want to
have included in the deletion process by using patterns. The <i>exclude</i>
attribute is used to specify
the files you want to have excluded from the deletion process. This is also
done with patterns. And
finally with the <i>defaultexcludes</i> attribute, you can specify whether you
want to use default exclusions or not. See the section on <a
href="#directorybasedtasks">directory based tasks</a>, on how the
inclusion/exclusion of files works, and how to write patterns. The patterns
relative to the <i>deldir</i> directory.</p>
<table border="1" cellpadding="2" cellspacing="0">
    <td valign="top"><b>Attribute</b></td>
    <td valign="top"><b>Description</b></td>
    <td align="center" valign="top"><b>Required</b></td>
    <td valign="top">deldir</td>
    <td valign="top">the directory to delete files from.</td>
    <td valign="top" align="center">Yes</td>
    <td valign="top">includes</td>
    <td valign="top">comma separated list of patterns of files that must be
      deleted. All files are in the current directory 
      and any sub-directories are deleted when omitted.</td>
    <td valign="top" align="center">No</td>
    <td valign="top">excludes</td>
    <td valign="top">comma separated list of patterns of files that must be
      excluded from the deletion list. No files (except default excludes)
are excluded when omitted.</td>
    <td valign="top" align="center">No</td>
    <td valign="top">defaultexcludes</td>
    <td valign="top">indicates whether default excludes should be used or not
      (&quot;yes&quot;/&quot;no&quot;). Default excludes are used when
    <td valign="top" align="center">No</td>
<pre>  &lt;deletefiles deldir=&quot;lib&quot; /&gt;</pre>
<p>deletes all files in the <code>/lib</code> directory.</p>
<pre>  &lt;deletefiles deldir=&quot;.&quot;
<p>deletes all files with the extension &quot;<code>.bak</code>&quot
the current directory 
and any sub-directories.</p>

As an aside - is the set of default excludes defined anywhere other than
the source?? I'm presuming that the definition found in class
DirectoryScanner is it.

     * Patterns that should be excluded by default.
     * @see #addDefaultExcludes()
    private final static String[] DEFAULTEXCLUDES = {

       Tom Dimock  ----  Cornell University  ----
"There go my people.  I must follow them, for I am their leader."  M. Gandhi

View raw message