ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Aloizio Pereira da Silva <aloi...@dcc.ufmg.br>
Subject RE: Changing the properties value.
Date Thu, 16 Oct 2003 10:15:04 GMT
Hi,

There is a problem with your solution, I need to change the var1 value and
not should create another property var2.

            *****************************************************
            *         Federal University of Minas Gerais        *
            *          Department of Computer Science          *
            *         Master Degree in Computer Science         *
            *                                                   *
            *                 Aloizio Silva                     *
            *         http://www.dcc.ufmg.br/~aloizio          *
            *                                                   *
            *      Mobile Computer and Network Optimization     *
            *****************************************************

On Wed, 15 Oct 2003, Thomas, Lee E wrote:

> Here is what I came up with.
>
> The following example supports what Jack wrote.
>
> If you set a property to a certain value in a task the property keeps
> that value for the life of the task. The value is seen by all other
> tasks that the original task calls (the invocation stack). On the other
> hand if the property is originally declared in one of the called tasks
> then the property losses its definition (value) when it returns to the
> calling task.
>
> Thanks.
>
> - Lee
>
>
> Ant script
> ********************************************************************
>
> <?xml version="1.0" encoding="UTF-8"?>
>
>
> <project name="leetest" default="test" basedir=".">
>
>
> 	<target name="setup" description="set up property">
>
> 	<echo message="start of test"/>
>
> 	<property name="var1" value="first value"/>
> 		<echo message="value of var1 in setup is: ${var1}"/>
>
> 	</target>
>
>
> 	<target name="test" description="test parm setting"
> depends="setup">
>
> 		<echo message="value of var1 in test is: ${var1}"/>
>
> 		<property name="var1" value="second value"/>
> 			<echo message="value of var1 in test after
> change is: ${var1}"/>
>
> 		<antcall target="test2"/>
>
> 		<property name="var2" value="var2 second value"/>
>
> 		<echo message="value of var2 in test after change is:
> ${var2}"/>
>
> 		<echo message="end of test"/>
>
> 	</target>
>
> 	<target name="test2" description="" >
>
> 	<echo message="value of var1 in test2 is: ${var1}"/>
>
> 			<property name="var1" value="second value"/>
> 				<echo message="value of var1 in test2
> after change is: ${var1}"/>
>
> 			<property name="var2" value="var2 first value"/>
> 				<echo message="value of var2 in test2
> after change is: ${var2}"/>
>
> **************************************************************
> Output of the script
>
> Buildfile: leetest2.xml
>
> setup:
>      [echo] start of test
>      [echo] value of var1 in setup is: first value
>
> test:
>      [echo] value of var1 in test is: first value
>      [echo] value of var1 in test after change is: first value
>
> test2:
>      [echo] value of var1 in test2 is: first value
>      [echo] value of var1 in test2 after change is: first value
>      [echo] value of var2 in test2 after change is: var2 first value
>      [echo] value of var2 in test after change is: var2 second value
>      [echo] end of test
>
> BUILD SUCCESSFUL
>
>
> 	</target>
>
> -----Original Message-----
> From: Jack Woehr [mailto:jax@purematrix.com]
> Sent: Wednesday, October 15, 2003 12:20 PM
> To: Ant Users List
> Subject: Re: Changing the properties value.
>
>
> "Shatzer, Larry" wrote:
>
> > From the manual on the task <property>
> > http://ant.apache.org/manual/CoreTasks/property.html
> >
> > Properties are immutable: whoever sets a property first freezes it for
>
> > the rest of the build; they are most definately not variable.
>
> That's true but a little misleading, in view of the fact that an <ant>
> or <antcall> caller can set a property for the called target and the
> setting doesn't propagate back to the caller's environment. So you can
> have a target algorithmically setting a property multiple times; these
> are just not really the "same property".
>
>
> --
> Jack J. Woehr            # "[F]ar in the empty sky a solitary esophagus
> slept
> http://www.well.com/~jax #  upon motionless wing; everywhere brooded
> stillness, http://www.softwoehr.com #  serenity, and the peace of God."
> - Mark Twain
>
>
>
>
> ---------------------------------------------------------------------
> 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