ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Alan Pearlman Spencer" <>
Subject RE: Is there a way to search a directory structure?
Date Wed, 14 Nov 2001 17:32:51 GMT
Thanks a million!
I'll play with the file attribute, don't know how I missed that!

-----Original Message-----
From: Diane Holt []
Sent: 14 November 2001 17:06
To: Ant Users List
Subject: Re: Is there a way to search a directory structure?

--- Alan Pearlman Spencer <> wrote:
> Can this type of thing work for searching a dir tree?
> I cant get it to work?
> I'm trying to search for a file anywhere in a dir tree and set a
> property if that is there.
> Like the available task, but I can't see how to get it to search a
> complete tree.
> I've tried:
> <available resource="my.file.txt" type="file" property="found">

The "resource" attribute is used when you're looking for something in a
jar-file. The "type" attribute is only valid when you've specified a
via the "file" attribute, as what you're looking for (and should check
that and print an error -- my bad, so I'll fix that :)

>   <classpath>
>     <fileset dir="${search.root}">
>       <include name="**"/>
>       <exclude name="**/*.*"/>
>     </fileset>
>   </classpath>

The nested <classpath> is used when you've specified you're looking for
either a class or a resource, not when you're looking for a file (or

The documentation says you can use a nested <filepath> element when
looking for a file (or directory), but I can't get that to work, so
I'm not doing it right, or there's a bug in how it's doing it (I'm
towards that :)

For example, I tried:
  <target name="findFile">
    <available property="found" file="">
        <fileset dir=".">
          <include name="**"/>
    <echo message="found = ${found}"/>

Running this target with -verbose shows it recursively searching through
all the subdirs, so that's good -- but it looks like it's made the
filename it's looking for the full-path name, based on the basedir, so
even though the file exists several subdirectories down from basedir,
not going to match.

Even more unfortunately, though, I tried just 'touch'ing an in
local directory, and it didn't find it there, either :(  Looks like some
debugging is in order.



Do You Yahoo!?
Find the one for you at Yahoo! Personals

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

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

View raw message