You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Andres Alleva <aa...@sdd.com.ar> on 2007/05/29 21:38:51 UTC

iterate a fileset

Hello!

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?

Thank u

Andres!


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


RE: iterate a fileset

Posted by "Rebhan, Gilbert" <Gi...@huk-coburg.de>.
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


Re: iterate a fileset

Posted by Andres Alleva <aa...@sdd.com.ar>.
Thanks! :)

David Weintraub escribió:
> Not sure if you're interested in the Ant Contrib tasks, but there is a
> <foreach> task in the AntContrib that will do exactly what you want.
> See: <http://ant-contrib.sourceforge.net/tasks/tasks/index.html> for
> more information.
>
> On 5/29/07, Andres Alleva <aa...@sdd.com.ar> wrote:
>> Hello!
>>
>> 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?
>>
>> Thank u
>>
>> Andres!
>>
>>
>> ---------------------------------------------------------------------
>> 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


Re: iterate a fileset

Posted by David Weintraub <qa...@gmail.com>.
Not sure if you're interested in the Ant Contrib tasks, but there is a
<foreach> task in the AntContrib that will do exactly what you want.
See: <http://ant-contrib.sourceforge.net/tasks/tasks/index.html> for
more information.

On 5/29/07, Andres Alleva <aa...@sdd.com.ar> wrote:
> Hello!
>
> 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?
>
> Thank u
>
> Andres!
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org
>
>


-- 
--
David Weintraub
qazwart@gmail.com

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