On Wed, 24 Jan 2007, Mikael Sitruk <[EMAIL 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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to