ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jay Dickon Glanville" <>
Subject how to set a property based on the contents of files in a tree?
Date Mon, 05 Nov 2007 18:36:47 GMT
Hello all,

I'm doing something, but I'm not sure I'm doing it the best way
possible.  So, I thought I'd ask the experts.

What I want to do is set a property if at least one file in a
directory tree contains a regular expression X.  Here's what I'm

Create a fileset containing all files that match this condition:
  <fileset dir="WebInfra/Source" id="fileset" includes="**/*">
    <containsregexp expression="dg" />

Convert that fileset to a string that contains the filenames in the fileset:
  <pathconvert pathsep="--" property="files_path" refid="fileset" />

Set the property if the filename string is longer then 0:
  <condition property="prop_from_condition" value="true">
    <length string="${files_path}" trim="true" when="greater" length="0" />

So, is this the best way to set a property to true if a directory tree
contains a file that matches a RegEx?  Is there a better way?



PS: I'm limited by my current environment to ant 1.6.5.

Jay Dickon Glanville

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

View raw message