ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Matt Benson <gudnabr...@yahoo.com>
Subject RE: Changing the properties value.
Date Wed, 15 Oct 2003 18:02:58 GMT
All:  Don't forget the other option that exists;
Antelope has a <variable> task that behaves as a
mutable property, taking advantage of the fact that
the immutabiility of properties is only enforced by
code.

-Matt

--- "Thomas, Lee E" <Lee.E.Thomas@erac.com> 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
> 


__________________________________
Do you Yahoo!?
The New Yahoo! Shopping - with improved product search
http://shopping.yahoo.com

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


Mime
View raw message