ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dominique Devienne <>
Subject Re: trying to grep in file for a certain string
Date Mon, 21 Nov 2005 17:06:46 GMT
> I am trying to check if a file called TestSummary.txt does NOT contains the string "Number
of failures = 0".
> If it does not contain "Number of failures = 0" then I need to set a property called
> When I try to test the ant script below I get:

<fileset> indeed doesn't support nested conditions, but selectors instead.

Use <loadfile> to put the file (or part of it as I do below) into a
property, and then simply test it with an <equals> condition to set
another property in a <condition>.

        <loadfile property="@{property}" failonerror="false" srcfile="@{file}">
            <!-- Consider only the last 10 lines of the file, -->
            <tailfilter />
            <!-- looking for a integer then a user-defined pattern, -->
              <regexp pattern="^\d+ @{pattern}" />
            <!-- and keep only the integer from these (unique) lines, -->
              <replaceregex pattern="(\d+) @{pattern}.*" replace="\1" />
            <!-- concatenating these lines (should be only one). -->
        <property name="@{property}" value="@{default}" />

PS: This code was part of a macrodef. Ignore the @{foo} syntax.

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

View raw message