ant 讀取環境變量的值

參考: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>


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章