ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Matt Benson <gudnabr...@yahoo.com>
Subject Re: AW: Checking for files in a directory
Date Wed, 14 Mar 2007 15:22:02 GMT

--- Jan.Materne@rzf.fin-nrw.de wrote:

> Just an idea ...
> 
> <property name="includes"
> value="these;files;must;be;present"/>
> <property name="includes.length" value="5"/>
> <property name="dir" value="dir"/>
> 
> <condition propery="all-files-present">
>     <length length="${includes.length}">
>         <fileset id="fs" dir="${dir}"
> includes="${includes}"/>
>     </length>
> </condition>
> 

Of course by now Jan has realized that <resourcecount>
was the condition to use rather than <length>.  ;)

Other thoughts:  if your list was e.g. 50 files as you
mentioned, especially if you think that list (I
believe you mentioned the idea of maintaining the list
in an external file) might change oftener than you'd
like to be modifying your Ant file, you might want to
make your Ant file be independent of the number of
files.  This is slightly problematical, but if you can
make the blanket assumption that your includesfile
contains no wildcards it's not too bad.  One example
assuming that ${basedir} contains an includesfile,
named includesfile:

<resourcecount property="expectedfiles">
  <tokens>
    <file file="includesfile" />
  </tokens>
</resourcecount>

<fail>
  <condition>
    <resourcecount when="ne" count="${expectedfiles}">
      <fileset dir="yourdir"
               includesfile="includesfile" />
    </resourcecount>
  </condition>
</fail>

HTH,
Matt

> 
> 
> Jan
> 
> >-----Ursprüngliche Nachricht-----
> >Von: Shankar S [mailto:shanki@gmail.com] 
> >Gesendet: Mittwoch, 14. März 2007 01:59
> >An: user@ant.apache.org
> >Betreff: Checking for files in a directory
> >
> >Hi,
> >
> >Is there a way in ANT where I could check if a list
> of files is
> >available/present in a directory instead of having
> a long list of
> ><available>s under <condition>?
> >Any help will be much appreciated.
> >
> >-Shankar
> >
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> user-unsubscribe@ant.apache.org
> For additional commands, e-mail:
> user-help@ant.apache.org
> 
> 




 
____________________________________________________________________________________
Need Mail bonding?
Go to the Yahoo! Mail Q&A for great tips from Yahoo! Answers users.
http://answers.yahoo.com/dir/?link=list&sid=396546091

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Mime
View raw message