• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Mutable Property in Ant Script

 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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




 
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Saloon Keeper
Posts: 27762
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Where does a nanny get ground to air missles? Protect this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic