參考:http://taink.iteye.com/blog/599735
<!-- 指定環境變量參數爲:SystemVariable -->
<property environment="SystemVariable" />
<!-- 將tomcat.home指向環境變量TOMCAT_HOME指向的路徑 -->
<property name="tomcat.home" value="${SystemVariable.TOMCAT_HOME}" />
<target name="display">
<echo message="${tomcat.home}" />
<mkdir dir="${tomcat.home}/test"/>
</target>
實例 <property name="manager.url" value="http://localhost:8080/manager"/>
<!-- 指定環境變量參數爲:SystemVariable -->
<property environment="SystemVariable" />
<!-- 將tomcat.home指向環境變量TOMCAT_HOME指向的路徑 -->
<property name="java.home" value="${SystemVariable.JAVA_HOME}" />
<target name="compile">
<echo message="${java.home}" />
<javac srcdir="${src}"
<classpath id="classpath">
<fileset dir="${java.home}\lib"><!--讀取環境變量中的JAVA_HOME設置ant-->
<include name="**/*.jar"/>
</fileset>
<fileset dir="${lib}">
<include name="**/*.jar"/>
</fileset>
</classpath>
</javac>
</target>