Actually, I find <var> very useful myself... I don't abuse it - but do
find I need it once in awhile. For instance, I have some macrodef's
where I absolutely need mutability. I can simply define my macrodef and
use a known property and vary its contents for each invocation of my
macrodef...just like if I wrote a function in java and used a local
variable in a method. However, in vanilla targets I don't find I ever
use <var> - so your point is well taken ;)
Still I can't figure out why calling the target, echoval, from the
script shows the initial value and not the new value... Unless its some
issue like an <antcall inheritAll = "false".../> kind of thing,,,
Dominique Devienne wrote:
I guess that's why properties are immutable in Ant ;-)
I've build a lot of different projects, and I've never ever needed
<var>. I really surprised some people find it so useful. It's a loop
hole in Ant kept open for BC only. Just forget about <var> ;-) --DD
On 6/5/06, Scot P. Floess <[EMAIL PROTECTED]> wrote:
Can someone please look at the following and explain the behavior I am
seeing?
<project name = "MyProject">
<taskdef resource = "net/sf/antcontrib/antlib.xml"/>
<script language="javascript">
<![CDATA[
echo = MyProject.createTask ( "echo" );
variable = MyProject.createTask ( "var" );
variable.setName ( "theVal" );
variable.setValue ( "foo" );
variable.execute ();
echo.setMessage ( "Javascript = " + MyProject.getProperty (
"theVal" ) );
echo.perform ();
echoval.execute ();
variable.setName ( "theVal" );
variable.setValue ( "bar" );
variable.execute ();
echo.setMessage ( "Javascript = " + MyProject.getProperty (
"theVal" ) );
echo.perform ();
echoval.execute ();
]]>
</script>
<echo message = "After Javascript = ${theVal}"/>
<target name="echoval">
<echo>echoval = ${theVal}</echo>
</target>
</project>
Buildfile: build.xml
[echo] Javascript = foo
[echo] echoval = foo
[echo] Javascript = bar
[echo] echoval = foo
[echo] After Javascript = bar
Basically, when I set some value in the script, I see the correct value
from within the script...and as well as once the script ends...
However, in the script when I call out to a target, the value is
unchanged. I'm not sure if this is a scoping issue or if I am calling
out incorrectly?
I looked over the online docs for <script> and it says I have access to
all items of the project from the script (which clearly I do). However,
the curious part is that I do set the value theVal in the script and can
see the value changing...but when I call out to the target, echoval,
theVal maintains the same value as its initial value.
I tried different variations of the above - using project instead of
MyProject, etc. I found the results to be the same.
Many thanks ahead of time!
Scot
--
Scot P. Floess
27 Lake Royale
Louisburg, NC 27549
252-478-8087 (Home)
919-754-4592 (Work)
Chief Architect JPlate http://sourceforge.net/projects/jplate
Chief Architect JavaPIM http://sourceforge.net/projects/javapim
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
--
Scot P. Floess
27 Lake Royale
Louisburg, NC 27549
252-478-8087 (Home)
919-754-4592 (Work)
Chief Architect JPlate http://sourceforge.net/projects/jplate
Chief Architect JavaPIM http://sourceforge.net/projects/javapim
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]