wood burning stoves 2.0*
The moose likes Ant, Maven and Other Build Tools and the fly likes different target calling different properties Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Engineering » Ant, Maven and Other Build Tools
Bookmark "different target calling different properties" Watch "different target calling different properties" New topic
Author

different target calling different properties

siba swain
Greenhorn

Joined: Jul 04, 2011
Posts: 10
Hello All,

Currntly I have one requirement to load propeties based on target I am calling. I have 4 targets and each targets are for different environment like env1,env2,env3,env4

property files are env1.propeties,env2.propeties,env3.propeties,env4.propeties and Targets are as follows:



So this target depends on init.I want my properties for this environment get loaded before init gets called.

I dont want to use command line argument option to load the properties.Is there any other alternative???

Appreciate for help

Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5811
    
    7

Wow, there are several way to do this. Here's one:



Here's another:




and run it as:

ant -Denv=env1


JBoss In Action
siba swain
Greenhorn

Joined: Jul 04, 2011
Posts: 10
As mentioned I dont want to pass any argument like -Denv=??? . Currently I have implented in the 1st mention way. but the problem is if I have 4 environments then I have to repeat the following code 4 times



Thanks for your reply.
Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5811
    
    7

Maybe by using <ancall> you can avoid having targets env1, env2, env3 and env4. Something like this:



You might even be able to condense this into a single antcall by using the <for> tag from antcontrib.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: different target calling different properties
 
Similar Threads
Best strategy to run configurable tasks in Ant for configurable EAR contents
Extending MessageResources in Struts
Help with Combo box and action listener
ANT - query
Using ANT to deploy