ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Rebhan, Gilbert" <>
Subject RE: AW: Reversing a list
Date Wed, 05 Aug 2009 13:45:21 GMT
P.S. :

using $attributes.get('in').split(',') because i assumed
your list is given comma separated, f.e. like being set via

<property name="mylist" value="name1,name2,ant,forum,nabble"/>

Regards, Gilbert

-----Original Message-----
From: Rebhan, Gilbert 
Sent: Wednesday, August 05, 2009 3:42 PM
To: 'Ant Users List'
Subject: RE: AW: Reversing a list


-----Original Message-----
From: Raagu [] 
Sent: Wednesday, August 05, 2009 3:17 PM
Subject: Re: AW: Reversing a list



How can i access the the newlist here (outside <groovy> task)
I tried             ${list}
But it is giving old values .. which is set initially..
please do reply.


using ruby as scripting language, but it's similar for any scripting
running with BSF, means simply use the ant api.
So for using your newlist outside your script task you have to set
a new property with its value for further processing in your ant script

example with ruby =

<scriptdef name="mylistutil" language="ruby">
  <attribute name="in"/>
  <attribute name="out"/>
  <attribute name="filter"/>
  if $attributes.get('filter').nil?
    $project.setProperty $attributes.get('out') ,
    $project.setProperty $attributes.get('out') ,
       reject!{|i| i =~ /#{$attributes.get('filter')}/}.reverse.join(',').to_s

and then if filtering (filter attribute takes a regex) wanted just use scriptdef
with filter attribute, f.e. =

<mylistutil in="${mylist}" out="newlist" filter="2$"/>

filters all elements ending with 2 and gives newlist =

<mylistutil in="${mylist}" out="newlist"/>

runs without filtering and gives newlist =

*** if you want to overwrite your property mylist, then use mylist in out attribute
and ${mylist} (which is immutable normally) will get overwritten, f.e.

<mylistutil in="${mylist}" out="mylist"/>

Regards, Gilbert

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

View raw message