ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Erik Hatcher" <>
Subject Re: Delete and File Properties
Date Wed, 12 Jun 2002 20:00:03 GMT
A good solution is to use Ant 1.5's new selector capability.  Unfortunately
there is not a selector to filter out read-only files built-in.  But the
selector feature is extensible.  I hope I'm not giving away the farm on our
upcoming Ant book, but I was going to add this to Ant 1.6 anyway.  Here is a
custom selector to select only read-only files:

package org.example.antbook;



public class ReadOnlySelector extends BaseExtendSelector {
    public boolean isSelected(File basedir, String filename, File file)
            throws BuildException {
        return (!file.canWrite());

Here's how I use it:

    <selector id="selector">
      <custom classname="org.example.antbook.ReadOnlySelector"

    <copy todir="${temp.dir}">
      <fileset dir="${data.dir}">
        <selector refid="selector"/>

If you wanted to invert the selection to choose only non-read-only files,
simply wrap it with the <not> selector container.


----- Original Message -----
From: "Tim Walker" <>
To: <>
Sent: Wednesday, June 12, 2002 3:45 PM
Subject: Delete and File Properties

> Hello,
> Unfortunately we have .class files checked in to the main project stream.
Someday these will go away. My
> problem now is that I'd like to be able to do a clean, but with respect
for the file Read-Only property (i.e.
> delete all class files except the read only ones). Currently, it looks
like the Ant delete task doesn't care
> and always deletes files matching the fileset criteria.
> Thanks,
> --
> Tim Walker
> Senior Software Engineer
> Freshwater Software
> 303-443-2266 ex. 6505
> Looking for Answers to your SiteScope or SiteSeer questions?
> --
> To unsubscribe, e-mail:   <>
> For additional commands, e-mail: <>

To unsubscribe, e-mail:   <>
For additional commands, e-mail: <>

View raw message