I\'m trying to set up a machine-independent build environment for a Spring framework project, and my ant configuration appears to be not working. I\'ve searched quite a bit but
If anyone else is still struggling to make this work (like I did), and you can't (or would rather not) use export
for all your properties, try set -a
as suggested here
Add the following line to the build.xml
file:
<property environment="env"/>
to define the prefix when referencing environment variables. From the Property reference page for the environment attribute:
the prefix to use when retrieving environment variables. Thus if you specify environment="myenv" you will be able to access OS-specific environment variables via property names "myenv.PATH" or "myenv.TERM". Note that if you supply a property name with a final "." it will not be doubled; i.e. environment="myenv." will still allow access of environment variables through "myenv.PATH" and "myenv.TERM". This functionality is currently only implemented on select platforms. Feel free to send patches to increase the number of platforms on which this functionality is supported ;). Note also that properties are case-sensitive, even if the environment variables on your operating system are not; e.g. Windows 2000's system path variable is set to an Ant property named "env.Path" rather than "env.PATH".
I hope you are declaring <property environment="env."/>
before using env.
notation.
Also, below is the syntax in your build script to set specific environment variables.
**Windows and OS/2**
Assume Ant is installed in c:\ant. The following sets up the environment:
set ANT_HOME=c:\ant
set JAVA_HOME=c:\jdk-1.5.0.05
set PATH=%PATH%;%ANT_HOME%\bin
**Linux/Unix (bash)**
Assume Ant is installed in /usr/local/ant. The following sets up the environment:
export ANT_HOME=/usr/local/ant
export JAVA_HOME=/usr/local/jdk-1.5.0.05
export PATH=${PATH}:${ANT_HOME}/bin
**Linux/Unix (csh)**
setenv ANT_HOME /usr/local/ant
setenv JAVA_HOME /usr/local/jdk/jdk-1.5.0.05
set path=( $path $ANT_HOME/bin )
Having a symbolic link set up to point to the JVM/JDK version makes updates more seamless.