ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Dominique Devienne" <ddevie...@gmail.com>
Subject Re: Curious behavior calling target from script...
Date Mon, 05 Jun 2006 12:46:11 GMT
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 <floess@mindspring.com> 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: 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


Mime
View raw message