ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David Weintraub <>
Subject Re: Fail if any of many files contains a string
Date Thu, 11 Jun 2009 13:28:06 GMT
I haven't used it, but you might want to look at "loadresource". This loads
a resource into a property, but you can use the resource filters on it. This
would allow you to load a text resource into a property, but only those
lines that contain that regex you're looking for.

Then, you could check to see if your property is empty or not.

Since you're using antcontrib, you can use the <var> task instead of
<property> which would allow you to reset it each time.

The other possibility is to use a fileset of all of your files, and check
them all in one shot. Of course, you wouldn't know which file has the
string, but you'd have your task of failing the build.

On Wed, Jun 10, 2009 at 9:35 PM, jbmdharris <> wrote:

> Is there a way to check if a string is present in any of a set of files and
> fail the build?  I've got something now, but it requires copying the
> files... which I don't like doing.  Copying puts a bunch of "copying 1 file
> to blah blah blah in my build output".  Here's my current code:
>        <for param="currentCSSFile">
>            <path>
>                <fileset dir="${dir.out.css}">
>                    <include name="**/*.css"/>
>                </fileset>
>            </path>
>            <sequential>
>                <copy file="@{currentCSSFile}" tofile="${tokenCheckFile}"
> overwrite="true">
>                    <filterchain>
>                        <stripjavacomments/>
>                        <linecontainsregexp>
>                            <regexp pattern="@(.*?)@"/>
>                        </linecontainsregexp>
>                    </filterchain>
>                </copy>
>                <fail message="Found missed keyword substitution (@KEYWORD@
> )
> in output file: @{currentCSSFile}">
>                    <condition>
>                        <length file="${tokenCheckFile}" when="greater"
> length="0"/>
>                    </condition>
>                </fail>
>            </sequential>
>        </for>
> --
> View this message in context:
> Sent from the Ant - Users mailing list archive at
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:
> For additional commands, e-mail:

David Weintraub

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message