<property environment="env"/>
<echo message="TMP = ${env.TMP}"/>
Ant의 환경 변수는 환경에 대한 속성을 생성하고 이름을 지정하여 액세스 할 수 있습니다. 그런 다음 속성 이름을 사용하여 변수에 액세스 할 수 있습니다.
이 예제는 출력에서 tmp 환경 변수의 내용을 보여줍니다. 우선 환경이 env 속성에로드됩니다. 그런 다음 $ {env.TMP}를 사용하여 tmp 변수에 액세스합니다. 값이 출력에 기록 된 후
<project name="MyProject" default="test" basedir=".">
<target name="test">
<!-- Load the environment properties -->
<property environment="env"/>
<!-- Show the TMP in the output -->
<echo message="TMP = ${env.TMP}"/>
</target>
</project>
V:\tmp\ant>ant
Buildfile: build.xml
test:
[echo] TMP = C:\Users\Olivier\AppData\Local\Temp
BUILD SUCCESSFUL
Total time: 0 seconds