ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Tim Walker <twal...@merc-int.com>
Subject RE: Delete and File Properties
Date Wed, 12 Jun 2002 21:22:36 GMT
Hmmm...that didn't seem to work. 

I installed 1.5:
Ant -version Apache Ant version 1.5Beta2 compiled on May 31 2002

When I added it to my build script, Forte For Java (using 1.4 still complained) that nested
selectors were
disallowed (getting FFJ to use the new Ant is my next challenge). 

So...just running from a command prompt:

ant -verbose -debug -buildfile build.xml clean >antclean.log

I see the file and the [deleting] for files that have read only properties. I'm pretty sure
my script is
right...because if I don't have it right, I get class not found, etc. 

<selector id="selector">
    <custom classname="COM.ant.ReadOnlySelector" classpath="${classes.dir}"/>
  </selector>
 
  <target name="clean">
    <!-- Delete the ${build} and ${dist} directory trees -->
    <delete dir="${build}"/>
    <delete dir="${dist}"/>
    <delete>
       <fileset dir="${classes.dir}" includes="**/*.class">
            <selector refid="selector"/>
       </fileset>
    </delete>
  </target>

Any ideas ? Thanks again. 

--
Tim Walker
Senior Software Engineer
twalker@freshwater.com
Freshwater Software
303-443-2266 ex. 6505
Looking for Answers to your SiteScope or SiteSeer questions?
http://www.freshwater.com/support/search.htm


-----Original Message-----
From: Erik Hatcher [mailto:jakarta-ant@ehatchersolutions.com] 
Sent: Wednesday, June 12, 2002 2:00 PM
To: Ant Users List
Subject: Re: Delete and File Properties

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;

import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.types.selectors.BaseExtendSelector;

import java.io.File;

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"
classpath="${build.dir}"/>
    </selector>

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

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

    Erik



----- Original Message -----
From: "Tim Walker" <twalker@merc-int.com>
To: <ant-user@jakarta.apache.org>
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
> twalker@freshwater.com
> Freshwater Software
> 303-443-2266 ex. 6505
> Looking for Answers to your SiteScope or SiteSeer questions?
> http://www.freshwater.com/support/search.htm
>
>
>
> --
> To unsubscribe, e-mail:   <mailto:ant-user-unsubscribe@jakarta.apache.org>
> For additional commands, e-mail: <mailto:ant-user-help@jakarta.apache.org>
>
>


--
To unsubscribe, e-mail:   <mailto:ant-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:ant-user-help@jakarta.apache.org>

--
To unsubscribe, e-mail:   <mailto:ant-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:ant-user-help@jakarta.apache.org>


Mime
View raw message