개미 환경 변수를 얻는 방법

통사론:

<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


참고 문헌 :

Apache Ant

Ant property

최근 댓글