ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Sharad" <sha...@persistent.co.in>
Subject How to set new property in custom task to be available to the nexted tasks inside it?
Date Fri, 02 Jul 2004 11:16:37 GMT
Hi,

I want to create a custom task which would execute the tasks inside it
iteratively. For example I want a custom task "tokenizer" as follows :

<tokenizer delemeter="," inputstring="sharad,rajesh,praveen">
	<echo message="${tokenextracted}"/>
</tokenizer>

This tokenizer task should tokenize the inputstring using the specified
delemeter and should execute the tasks inside it with each time value of
property "tokenextracted" set to the token (i.e. sharad and rajesh and then
praveen). Irrespective of what are the nested tasks inside the tokenizer
task, all the tasks should be executed first time with the property
"tokenextracted" set to the token 'sharad', then all the tasks are executed
again with the value set to 'rajesh' and so on.

Attached is the custom task I tried. In the custom task, I tried to add/set
the property ${testing} in the execute method, so that this property can be
used in the nested tasks inside the tokenizer task. But it didn't work.
Following is my contents in one of the target of build.xml file using my
custom task "tokenizer":

<typedef name="mytask" classname="tokenizer" classpath="mylib"
loaderref="classes"/>
<mytask>
	<echo message="Value inside = ${testing}"/>
</mytask>
<echo message="Value outside = ${testing}"/>



The output I got is as follows :

Value inside = {testing}
Value outside = mytestingvalue


When I did a setNewProperty("testing","mytestingvalue") in the execute()
method of the custom task, the property is available to the tasks after this
but not to the tasks nested inside this task.

Can anyone please help me how to set the new property in my custom task so
that it should be available to the tasks inside my task.

Thanks and Regards,
Sharad.

Mime
View raw message