aspose file tools*
The moose likes Ant, Maven and Other Build Tools and the fly likes Mutable Property in Ant Script Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Engineering » Ant, Maven and Other Build Tools
Bookmark "Mutable Property in Ant Script" Watch "Mutable Property in Ant Script" New topic
Author

Mutable Property in Ant Script

Daksh Mital
Greenhorn

Joined: Aug 19, 2007
Posts: 19
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





Daksh
Ravindra Rawat
Ranch Hand

Joined: Dec 09, 2004
Posts: 34
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

Joined: Jun 25, 2001
Posts: 15661
    
  15

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.


Customer surveys are for companies who didn't pay proper attention to begin with.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Mutable Property in Ant Script
 
Similar Threads
Need help in build applications using ant : getting exception
Not able to display starting jsp page index.jsp
Submission Jar: test case + Ant build script
Ant does not output property file in classes folder.
Regarding Ant issue.