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 everyone seems to think that env.* references work out of the box. Could someone perhaps find the error of my ways?
The error:
bash-3.1$ ant build
Buildfile: c:\Users\mkumpan\Projects\Spring testing\build.xml
BUILD FAILED
c:\Users\mkumpan\Projects\Spring testing\build.xml:85: c:\Users\mkumpan\Projects\Spring testing\${env.CATALINA_HOME}\lib does not exist.
build.xml:85:
<taskdef name="install" classname="org.apache.catalina.ant.InstallTask">
<classpath refid="catalina-ant-classpath"/>
</taskdef>
catalina-ant-classpath reference:
<path id="catalina-ant-classpath">
<fileset dir="${appserver.lib}">
<include name="catalina-ant.jar"/>
</fileset>
</path>
${appserver.lib} declared in build.properties:
appserver.home=${env.CATALINA_HOME}
appserver.lib=${appserver.home}/lib
deploy.path=${appserver.home}/webapps
Echoing the envvar works:
bash-3.1$ echo $CATALINA_HOME
C:\Program Files\Tomcat
The two big questions:
- Why the hell does it not parse out the envvar?
- Why the hell does it prepend the absolute path to the envvar?
Add the following line to the
build.xml
file:to define the prefix when referencing environment variables. From the Property reference page for the environment attribute:
I hope you are declaring
<property environment="env."/>
before usingenv.
notation.Also, below is the syntax in your build script to set specific environment variables.
Assume Ant is installed in c:\ant. The following sets up the environment:
Assume Ant is installed in /usr/local/ant. The following sets up the environment:
Having a symbolic link set up to point to the JVM/JDK version makes updates more seamless.
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, tryset -a
as suggested here