Oh, never mind, I solved my error by using the tags
<selector...>
<custom .../>
</selector...>
BUT, I'm still having problems creating the logic that I want, so please help me anywone!
What I want to do is to copy the file x.txt and y.txt to xprev.txt and yprev.txt ONLY if xprev.txt
and yprev.txt are write enabled.
How can I do that?
Regards
/ Lelle
>
>
> > On Sep 28, 2004, at 5:04 AM, Lennart Hellström (HF/EBC) wrote:
> > > I want to copy a file to a destination file only if the
> destination
> > > file is not readonly (it might be checked in on the
> version control
> > > system)
> > >
> > > I tried using <copy> with failOnError="false" but strangely
> > the build
> > > fails anyway when the destination file is readonly.
> > >
> > > Is there some way to look at the file's attributes before
> > deciding to
> > > copy or not?
> > > <Attrib> seems to only change the file attributes, and
> > that's not what
> > > I want.
> >
> > There may be other ways to do this, but as an example of writing a
> > custom selector I do this:
> >
> > <typedef name="readonly"
> > classname="ReadOnlySelector"
> > classpath="build/classes"
> > />
> >
> > <copy todir="build/copy">
> > <fileset dir="src">
> > <readonly/>
> > </fileset>
> > </copy>
> >
> > Where ReadOnlySelector is this:
> >
> > import org.apache.tools.ant.types.selectors.FileSelector;
> > import org.apache.tools.ant.BuildException;
> >
> > import java.io.File;
> >
> > public class ReadOnlySelector implements FileSelector {
> > public boolean isSelected(File basedir,
> > String filename,
> > File file) throws BuildException {
> > return !file.canWrite() && file.canRead();
> > }
> > }
> >
>
> Fine, thanks!
> With that implemented I now get the following error in my ant
> script: "The <fileset> data type doesn't support the nested
> "readonly" element. at line 296"
>
> Is there something else I need to do to make ant accept my
> custom selection?
>
> / Lelle
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org
|