wood burning stoves 2.0*
The moose likes Other Open Source Projects and the fly likes How to use the Ant Property file setting? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Products » Other Open Source Projects
Bookmark "How to use the Ant Property file setting?" Watch "How to use the Ant Property file setting?" New topic
Author

How to use the Ant Property file setting?

Roy Huang
Ranch Hand

Joined: Nov 21, 2001
Posts: 104
In the java ant samples, I have found some like
<property file="${env.ANT_HOME}/ant.properties" />.
My question is:
1. How to use the settings in the property files?
In java we can use Properties.load(Inputstream) and then use getProperty("key1") to get the value of key1. But How can I let my java code know it should load the property file from the Ant XML file setting? What should I use from the Ant API to bind with the ant xml file settings?
2. Does the ${env.ANT_HOME} also work for Windows NT platform? In my case, it doesn't work.
Thanks,
Roy


SCJP 1.4/SCBCD/SCWCD<br />MCSE<br />IBM professional XML Developer<br />SAP certified Development Consultant (NetWeaver portal and Web JavaApplication)
Lewin Chan
Ranch Hand

Joined: Oct 10, 2001
Posts: 214
Roy,
1) Just use them, like

where build.dir etc are just all defined in the property file.

It doesn't necessarily help your java code at all, but it can externalise any variables that you want in your build script into a properties file.
If you are intending to run your java code within ant, then they may be passed as part of the default system properties, or they may not.

2)
a) if ANT_HOME hasn't been defined in your environment then you won't be able to use it...
b) If you want to use environment variables, then you may need to use the

Task before you can reference variables as "${my_prefix.ENV_VAR}"
L


I have no java certifications. This makes me a bad programmer. Ignore my post.
 
 
subject: How to use the Ant Property file setting?
 
Similar Threads
How to set environmental variables from ANT?
server design...
Tomcat with [] and . operator
Test for APACHE_HOME in ANT
issue regarding running SVN checkout from ANT script