Reputation: 1
I have a cmd script file, which sets all the environment values and invoke ant class to build the java project.
I have:
<property environment="env"/>
set in build.xml and
<property name="CD" value="${env.CDTEC}"/>.
build.xml unable to read these env values set from the cmd script file. If I echo the values from command prompt that prints, but not from the ant.xml file. Getting the error as
BUILD FAILED
c:\Users\test\Projects\Spring testing\build.xml:85: c:\Users\test\Projects\Spring testing\${env.CDTEC}\lib does not exist.
I added echo message in build.xml as
<echo message="Message from ${this.CDTEC} Client" />
and printing that as
'Message from {env.CDTEC} Client'.
Command prompt is printing these values but Ant is not able to access these env values, any idea why?
Upvotes: 0
Views: 2872
Reputation: 77951
Is the environment variable set externally to ANT?
Setting the variable and calling ANT
$ CDTEC=hello ant
Buildfile: /....../build.xml
build:
[echo] CDTEC=hello
<project name="demo" default="build">
<property environment="env"/>
<target name="build">
<echo message="CDTEC=${env.CDTEC}"/>
</target>
</project>
Upvotes: 1