I am having a problem accessing environment variables in a netbeans build.xml ant script. Basically, when I use this code:
<target name="-pre-jar">
<property environment="env"/>
<echo message="${env.ANT_HOME}"/>
<echo message="${env.JAVA_HOME}"/>
</target>
I receive output as follows:
compile:
${env.ANT_HOME}
${env.JAVA_HOME}
This is a problem because I need to access those filepaths later in the script. Also, I am sure that those two are defined as environment variables. Here is some proof from my terminal:
Lukas-Rezeks-MacBook-Pro:ant lukas$ echo $JAVA_HOME - $ANT_HOME
/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home - /ant
Am I doing something wrong in the ant build scripts variable declaration, or am I missing something obvious? Any feedback would be appreciated. Thanks.
This is completely working for me on my OSX system:
You can either put
outside your target,
OR use "depends=" instead of "antcall" in your compile task.
I did the following test on my Linux:
and when I ran "ant compile" I got the following:
and when I used depends="pre-jar", the result was:
when I put outside any target, the result was: