天天看點

ant build.xml檔案中能使用的屬性介紹自定義屬性

ant.file:該建構檔案的完整位址

ant.version:安裝的 Apache Ant 的版本

basedir:建構檔案的基目錄的絕對路徑,作為 project 元素的 basedir 屬性

ant.java.version:Ant 使用的 JAVA 語言的軟體開發工具包的版本

ant.project.name:項目的名字,具體聲明為 project 元素的 name 屬性

ant.project.default-target:目前項目的預設目标

ant.project.invoked-targets:在目前項目中被調用的目标的逗号分隔清單

ant.core.lib:Ant 的 jar 檔案的完整的位址

ant.home:Ant 安裝的主目錄

ant.library.dir:Ant 庫檔案的主目錄,特别是 ANT_HOME/lib 檔案夾

看個例子:

<?xml version="1.0"?>
   <project name="Hello World Project" default="info">

   <target name="info">
      <echo>Hello World - Welcome to Apache Ant! + ${ant.file}</echo>
   </target>

</project>
      

輸出:

ant build.xml檔案中能使用的屬性介紹自定義屬性

自定義屬性

<?xml version="1.0"?>
<project name="Hello World Project" default="info">

   <property name="sitename" value="www.tutorialspoint.com"/>
   <target name="info">
      <echo>Apache Ant version is ${ant.version} - You are at ${sitename} </echo>
   </target>

</project>
      
ant build.xml檔案中能使用的屬性介紹自定義屬性