Hey Thanks for awesome reply..
I have done the same procedure.. I have included groovy jar file n excuted
groovy codes within <groovy></groovy> tags..

Now I am not getting How to pass a variable from <groovy> to the main
script.. i,e How Do i access a variable outside <groovy> tag.. The variable
is set within <groovy> tag..

Here is the sample snippet..
Here list is dynamic and it will keep changing..
that is why i have kept it in <var>

<var id="varID" name="list" value="one,two,three">
<groovy>
   //Here i am  accessing list as   "project.references.varId.list" . It
will give its values
   // Here i am doing all operation do reverse and filter
   //then i am doing   
   project.references.varId.list = newList
<groovy>

After this

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.




Jan.Materne wrote:
> 
> I dont know any core tasks. Maybe there are external tasks for that.
> Alternatively you could implement your own.
> 
> Jan
> 
> 
> <project>
> 
>     <property name="list"
> value="one,two,three,four,five,six,seven,eight,nine,ten"/>
>     <property name="ignore" value="two,four,six,eight,ten"/>
>     
>     <scriptdef name="revert" language="javascript">
>         <attribute name="list"/>
>         <attribute name="property"/>
>         <![CDATA[
>             listParts = attributes.get("list").split(",");
>             newValue = "";
>             for(i=listParts.length-1; i>=0; i--) {
>                 newValue += "," + listParts[i];
>             }
>             if (newValue.length > 0) {
>                 newValue = newValue.substring(1);
>             }
>             project.setNewProperty(attributes.get("property"), newValue);
>         ]]>
>     </scriptdef>
> 
>     <scriptdef name="filter" language="javascript">
>         <attribute name="list"/>
>         <attribute name="excludes"/>
>         <attribute name="property"/>
>         <![CDATA[
>             listParts = attributes.get("list").split(",");
>             exclParts = attributes.get("excludes").split(",");
>             newValue = "";
>             for(i=0; i<listParts.length; i++) {
>                 add = true;
>                 for(j=0; j<exclParts.length && add; j++) {
>                     add = !listParts[i].equals(exclParts[j]);
>                 }
>                 if (add) {
>                     newValue += "," + listParts[i];
>                 }
>             }
>             if (newValue.length > 0) {
>                 newValue = newValue.substring(1);
>             }
>             project.setNewProperty(attributes.get("property"), newValue);
>         ]]>
>     </scriptdef>
>     
>     
>     <filter property="filtered" list="${list}" excludes="${ignore}" />
>     <revert property="reverted" list="${filtered}"/>
>     <echo>
>        The original list   : ${list}
>        filtered list       : ${filtered}
>        reverted + filtered : ${reverted}
>     </echo>
> 
> </project>
> 
>  
> 
>>-----Ursprüngliche Nachricht-----
>>Von: Raagu [mailto:rknilekani2...@gmail.com] 
>>Gesendet: Mittwoch, 5. August 2009 11:46
>>An: user@ant.apache.org
>>Betreff: Reversing a list
>>
>>
>>Hello People
>>
>>I have a written a ant script which has a variable say "list" 
>>which contains
>>list of names say name1,name2,ant,forum,nabble     . All r 
>>comma separated..
>>
>>I want to reverse this list such dat , after reversing "list" 
>>should give me  
>>nabble,forum,ant,name2,name1..
>>
>>And also Is there any option to discard  some of the values 
>>from list..??
>>Please reply 
>>Thanks in advance
>>-- 
>>View this message in context: 
>>http://www.nabble.com/Reversing-a-list-tp24823814p24823814.html
>>Sent from the Ant - Users mailing list archive at Nabble.com.
>>
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: user-unsubscr...@ant.apache.org
>>For additional commands, e-mail: user-h...@ant.apache.org
>>
>>
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscr...@ant.apache.org
> For additional commands, e-mail: user-h...@ant.apache.org
> 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Reversing-a-list-tp24823814p24826789.html
Sent from the Ant - Users mailing list archive at Nabble.com.


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

Reply via email to