简体   繁体   中英

Ant build.xml not reading env properties

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?

Is the environment variable set externally to ANT?

Example

Setting the variable and calling ANT

$ CDTEC=hello ant
Buildfile: /....../build.xml

build:
     [echo] CDTEC=hello

build.xml

<project name="demo" default="build">

  <property environment="env"/>

  <target name="build">
    <echo message="CDTEC=${env.CDTEC}"/>
  </target> 

</project>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM