ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Matt Benson <gudnabr...@yahoo.com>
Subject Re: Fail if any of many files contains a string
Date Thu, 11 Jun 2009 12:20:41 GMT

I'm assuming you want to keep your per-file processing so you can identify the offending file.
 Instead of copying with filters, though, try nesting a <concat> (usable as a single-element
resourcecollection since 1.7.1) into your length condition.  Concat your fileset, embedding
your filterchain so that the resulting resource is the filtered resource.  Copying will then
be in-memory.

HTH,
Matt

--- On Wed, 6/10/09, jbmdharris <jbmdharris@hotmail.com> wrote:

> From: jbmdharris <jbmdharris@hotmail.com>
> Subject: Fail if any of many files contains a string
> To: user@ant.apache.org
> Date: Wednesday, June 10, 2009, 8:35 PM
> 
> 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: http://www.nabble.com/Fail-if-any-of-many-files-contains-a-string-tp23973929p23973929.html
> Sent from the Ant - Users mailing list archive at
> Nabble.com.
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org
> 
> 


      

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


Mime
View raw message