Java Mailing List Archive

http://www.ant-tasks.com/

Apache Ant Archive

» Ant Users List
» Ant Developers List
filelist/fileset with multiple directory

filelist/fileset with multiple directory

2007-01-24       - By Stefan Bodewig
Reply:     1     2     3     4     5     6     7     8     9     10  

On Wed, 24 Jan 2007, Mikael Sitruk <MikaelS@(protected)> wrote:

> I would like to know if it is possible to define a fileset/filelist
> that will return the first occurrence of the patterned file from a
> list of directories, like the java class loading and path.
>
> For example suppose we have 3 directories:
>
> Dir1: a.txt, b.java
>
> Dir2: a.txt,c:jar
>
> Dir3: b.java

I think you should be able to write a custom resource selector to do
this, let's say you'd typedef it as "returnfirstmatch" than you could
use it as

<restrict>
 <union>
   <fileset dir="Dir1"/>
   <fileset dir="Dir2"/>
   <fileset dir="Dir3"/>
 </union>
 <returnsfirstmatch/>
</restrict>

shouldn't be too difficult to do, but I don't think it can be done
with stock Ant, at least not in a generic way.  For you specific case

<union>
 <fileset dir="Dir1"/>
 <fileset dir="Dir2">
   <not>
     <present targetdir="Dir1"/>
   </not>
 </fileset>
 <fileset dir="Dir3">
   <not>
     <or>
       <present targetdir="Dir1"/>
       <present targetdir="Dir2"/>
     </or>
   </not>
 </fileset>
</union>

would work, but I'd really choose the custom selector route.

Stefan

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@(protected)
For additional commands, e-mail: user-help@(protected)


©2008 ant-tasks.com - Jax Systems, LLC, U.S.A.