Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Mutable Property in Ant Script

 
Daksh Mital
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All
I know the <property> task in ANt lest me define an immutable property.
I checked on net and found that using antcotrib.jar
one can define a mutable property (basically one whose value can be changed during run time)

I tried running the following sample code



But the response is something like


hoj: [echo] ---------->>>true [echo] ----------->>true
pqr: [echo] false [echo] false



When i make an ant call from one target to another the value in property just restores.

Can any body explain if this is default behavior or me missing something.
Immediate help would be appreciated




 
Ravindra Rawat
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You get the desired behavior if you change the global variable declarations as properties. Ant contrib documentation says properties can be overiden variables cannot may be something to do with it Documentation does not define behavior on antcalls, need to look at code to confirm.
 
Tim Holloway
Saloon Keeper
Pie
Posts: 18156
53
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ravindra Rawat wrote:You get the desired behavior if you change the global variable declarations as properties. Ant contrib documentation says properties can be overiden variables cannot may be something to do with it Documentation does not define behavior on antcalls, need to look at code to confirm.


Ant properties are immutable within an ant instance, and, unlike most property definitions, the first definition wins, not the last one. The command-line "-D" setting, pretty much overrules everything.

There are 2 ways for Ant to do a script call. Internally and externally. Ant can do an external ant script call and supply a whole new set of properties, but an internal call is stuck with the same properties as the caller has.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic