ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stefan Bodewig <bode...@apache.org>
Subject Re: filelist/fileset with multiple directory
Date Wed, 24 Jan 2007 19:28:49 GMT
On Wed, 24 Jan 2007, Mikael Sitruk <MikaelS@amdocs.com> 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@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Mime
View raw message