<!-- 指定環境變量參數為: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}">
</classpath>
</javac>
</target>
本文轉自xwdreamer部落格園部落格,原文連結:http://www.cnblogs.com/xwdreamer/archive/2011/11/21/2296929.html,如需轉載請自行聯系原作者