ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Rebhan, Gilbert" <Gilbert.Reb...@huk-coburg.de>
Subject RE: iterate a fileset
Date Wed, 30 May 2007 06:17:08 GMT

Hi,

-----Original Message-----
From: Andres Alleva [mailto:aalleva@sdd.com.ar] 
Sent: Tuesday, May 29, 2007 9:39 PM
To: user@ant.apache.org
Subject: iterate a fileset

/*
I need to check, if every .jsp in my project, contains a tag like this 
<tag=xxxx>
How can i iterate a fileset and use <contains...> for each of my files?
*/

something like =

<script language="ruby">
<![CDATA[
         jspfound=Array.new
         Dir['**/*.jsp'].each do |path|
             File.open( path ) do |f|
               f.grep( /your regex for versiontag goes here/ ) do |line|
                 jspfound<<path<<','
               end
             end
           end
            $project.setProperty "jspfiles", jspfound.to_s.chop
 ]]>
</script>


if you have declared the targetdir that should be scanned
as ant property, i.e.

<property name="jspdir" value="C:/jspfiles" />
you use =

<script language="ruby">
<![CDATA[
         jspfound=Array.new
          Dir[$project.getProperty('jspdir')+'/*.jsp']
	...

or recursive =

<script language="ruby">
<![CDATA[
         jspfound=Array.new
          Dir[$project.getProperty('jspdir')+'/**/*.jsp']
	...

gives you the files in a ', ' separated list as property
if you need another separator change the line =
jspfound<<path<<','

into 

jspfound<<path<<'your separator char'


Regards, Gilbert

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


Mime
View raw message