天天看點

ANT 标簽

2.Ant的任務:----------------------------------------------------------------

          ant              在另一個build file上調用ant

          antcall          調用一個目前build file上的target

          antstructure     建立一個ant build filde 的DTD文檔

          apply            執行系統指令,并應用檔案

          available        設定資源屬性

          chmod            設定變更檔案和檔案夾的變更權限(UNIX)

          condition        條件為真時設定屬性

          copy             拷貝檔案和目錄 

          copydir          instead by copy

          copyfile         instead by copy

          cvs              執行cvs指令

          cvspass          添加password到.cvspass檔案中

          delete           删除檔案和檔案夾

          deltree          use the delete task instead.

          dependset        管理檔案依賴關系

          ear              建立EAR檔案

          echo             寫出log到檔案或控制台

          exec             執行一個本地指令

          execon           use the apply task instead.

          fail             抛出BuildException,停止build指令

          filter           設定令牌過濾

          fixcrlf          清除源檔案中指定的特殊字元

          genkey           産生一個key

          get              從一個url上取得檔案(****,可以用來分發jar包)

          gunzip           解壓縮一個GZip檔案

          gzip             建立一個GZip檔案

          jar              建立一個JAR檔案

          java           

          javac            編譯java項目,并不等用于JDK中的javac指令

          javadoc

          mail             發送郵件(****)

          mkdir          

          move   

          parallel         在并發線程上執行多任務?

          patch            應用一個不同的檔案到原始檔案上

          pathconvert      轉換ant路徑到指定的平台路徑

          property

          record           Logs output from the current build process.

          rename           use the move task instead.

          replace          在檔案中替換字元串

          rmic             Runs the rmic compiler.

          sequential       順序執行多任務,用于并行任務

          signjar          Executes the javasign command-line tool.

          sleep            暫停編譯一段時間

          sql              使用JDBC指定SQL指令(****,執行資料庫初始化)

          style            執行XSLT轉換

          tar              建立一個TAR檔案

          taskdef          添加定義的任務到目前項目中

          touch            更新檔案的時間戳(****,應用于檔案版本)

          tstamp           Sets the DSTAMP, TSTAMP, and TODAY properties.

          typedef          Adds a DataType to the current project.

          unjar            Expands a ZIP file, WAR file, or JAR file.

          untar  

          unwar

          unzip

          uptodate         Sets a property if one or more target files are up-to-date with respect to corresponding source files.

          war

          zip

Ant Optional Task:----------------------------------------------------------------

          antlr            運作ANTLR分析器,Runs the ANTLR parser and translator generator tool.

          blgenclient      從一個已知的ejb-jar檔案中建立一個JAR檔案

          cab              建立微軟 .cab檔案

          cccheckin        執行ClearCase checkin 指令

          cccheckout       執行ClearCase checkout 指令

          ccuncheckout     執行ClearCase undocheckout 指令

          ccupdate         執行ClearCase update 指令

          ccmcheckin       執行一個Continuus1 ci 指令

          ccmcheckintask   執行一個Continuus1 ci 預設指令

          ccmcheckout      執行一個Continuus1 co 指令

          ccmcreatetask    執行一個Continuus1 create_task 指令

          ccmreconfigure   執行一個Continuus1 reconfigure 指令

          csc              編譯C#源檔案

          ddcreator        建立一個EJB部署描述符

          depend           根據時間戳判斷檔案是否過期

          ejbc             執行BEA WebLogic Server's ejbc tool, 産生部署EJB元件必要的代碼

          ejbjar           建立ejb-jar檔案,符合EJB1.1标準

          ftp              實作一個基本的ftp用戶端(****)

          icontract        Executes the iContract Design By Contract preprocessor.

          ilasm            Assembles .NET Intermediate Language files.

          iplanet-ejbc     Compiles EJB stubs and skeletons for iPlanet Application Server Version 6.0.

          javacc           Executes the JavaCC compiler compiler on a grammar file.

          javah            Executes the javah tool, generating Java Native Interface (JNI) headers from one or more Java classes.

          jdepend          Executes the JDepend tool.

          jjtree           Executes the JJTree preprocessor for JavaCC.

          jlink            Builds a JAR or ZIP file, optionally merging contents of existing JAR and ZIP    archives.

          jpcoverage       Executes the JProbe Coverage tool.

          jpcovmerge       Merges several JProbe Coverage snapshots into one.

          jpcovreport      Creates a report from a JProbe Coverage snapshot.

          junit            執行單元測試

          junitreport      建立一個單元測試報告

          maudit           執行WebGain 品質分析,分析java代碼錯誤

          mmetrics         執行WebGain 品質分析

          mimemail         發送SMTP郵件,并可發送附件

          mparse           all Executes the now obsolete Metamata MParse compiler compiler on a grammar file.

          native2ascii     轉換本地代碼到ASCII代碼

          netrexxc         Compiles a set of NetRexx files.

          p4change         Requests a new changelist from a Perforce server.

          p4counter        Gets and sets a Perforce counter value.

          p4edit           Opens files from Perforce for editing.

          p4have           Lists Perforce files in the current client view.

          p4label          Creates a label for files in the current Perforce workspace.

          p4reopen         Moves files between Perforce changelists.

          p4revert         Reverts opened Perforce files.

          p4submit         Checks files in to a Perforce depot.

          p4sync           Synchronizes a workspace with the Perforce depot.

          propertyfile     建立或變一個java屬性檔案

          pvcs             Extracts files from a PVCS repository.

          renameext        重命名檔案擴充名

          rpm              Builds a Linux RPM file.

          script           執行一個 BSF 腳本.

          sound            build結束後播放一個聲音檔案

          starteam         從StarTeam check Out file.

          stylebook        Executes the Apache Stylebook documentation generator.

          telnet           執行telnet會話

          test             執行單元測試,基于org.apache.testlet 架構

          vsscheckin       Checkin檔案到VSS上(****)

          vsscheckout      checkout檔案從vss上

          vssget           從vss上擷取最新的檔案

          vsshistory       顯示vss上檔案或項目曆史資訊

          vsslabel         标記 Assigns a label to files and projects in Visual SourceSafe.

          wljspc           Precompiles JSP files using BEA WebLogic Server's JSP compiler.

          wlrun            Starts an instance of the BEA WebLogic Server.

          wlstop           Stops an instance of the BEA WebLogic Server.

          xmlvalidate      驗證xml文檔格式,使用任何SAX分析器(**** ,驗證配置檔案)

Ant和XDoclet的整合:----------------------------------------------------------------

          僅僅需要拷貝Xdolcet.jar到ANT_HOME/lib目錄中即可

          這樣就可以內建XDoclet了

3.1 Projects

project有下面的屬性:

Attribute Description Required

name 項目名稱. No

default 當沒有指定target時使用的預設target Yes

basedir 用于計算所有其他路徑的基路徑。該屬性可以被basedir property覆寫。當覆寫時,該屬性被忽略。如果屬性和basedir property都沒有設定,就使用buildfile檔案的父目錄。 No

項目的描述以一個頂級的〈description〉元素的形式出現(參看description小節)。

一個項目可以定義一個或多個target。一個target是一系列你想要執行的。執行Ant時,你可以選擇執行那個target。當沒有給定target時,使用project的default屬性所确定的target。

3.2 Targets

一個target可以依賴于其他的target。例如,你可能會有一個target用于編譯程式,一個target用于生成可執行檔案。你在生成可執行檔案之前必須先編譯通過,是以生成可執行檔案的target依賴于編譯target。Ant會處理這種依賴關系。

然而,應當注意到,Ant的depends屬性隻指定了target應該被執行的順序-如果被依賴的target無法運作,這種depends對于指定了依賴關系的target就沒有影響。

Ant會依照depends屬性中target出現的順序(從左到右)依次執行每個target。然而,要記住的是隻要某個target依賴于一個target,後者就會被先執行。

〈target name="A"/〉

〈target name="B" depends="A"/〉

〈target name="C" depends="B"/〉

〈target name="D" depends="C,B,A"/〉

假定我們要執行target D。從它的依賴屬性來看,你可能認為先執行C,然後B,最後A被執行。錯了,C依賴于B,B依賴于A,是以先執行A,然後B,然後C,最後D被執行。

一個target隻能被執行一次,即時有多個target依賴于它(看上面的例子)。

如果(或如果不)某些屬性被設定,才執行某個target。這樣,允許根據系統的狀态(java version, OS, 指令行屬性定義等等)來更好地控制build的過程。要想讓一個target這樣做,你就應該在target元素中,加入if(或unless)屬性,帶上target因該有所判斷的屬性。例如:

〈target name="build-module-A" if="module-A-present"/〉

〈target name="build-own-fake-module-A" unless="module-A-present"/〉

如果沒有if或unless屬性,target總會被執行。

可選的description屬性可用來提供關于target的一行描述,這些描述可由-projecthelp指令行選項輸出。

将你的tstamp task在一個所謂的初始化target是很好的做法,其他的target依賴這個初始化target。要確定初始化target是出現在其他target依賴表中的第一個target。在本手冊中大多數的初始化target的名字是"init"。

target有下面的屬性:

Attribute Description Required

name target的名字 Yes

depends 用逗号分隔的target的名字清單,也就是依賴表。 No

if 執行target所需要設定的屬性名。 No

unless 執行target需要清除設定的屬性名。 No

description 關于target功能的簡短描述。 No

3.3 Tasks

一個task是一段可執行的代碼。

一個task可以有多個屬性(如果你願意的話,可以将其稱之為變量)。屬性隻可能包含對property的引用。這些引用會在task執行前被解析。

下面是Task的一般構造形式:

〈name attribute1="value1" attribute2="value2" ... /〉

這裡name是task的名字,attributeN是屬性名,valueN是屬性值。

有一套内置的(built-in)task,以及一些可選task,但你也可以編寫自己的task。

所有的task都有一個task名字屬性。Ant用屬性值來産生日志資訊。

可以給task賦一個id屬性:

〈taskname id="taskID" ... /〉

這裡taskname是task的名字,而taskID是這個task的唯一辨別符。通過這個辨別符,你可以在腳本中引用相應的task。例如,在腳本中你可以這樣:

〈script ... 〉

task1.setFoo("bar");

〈/script〉

設定某個task執行個體的foo屬性。在另一個task中(用java編寫),你可以利用下面的語句存取相應的執行個體。

project.getReference("task1").

注意1:如果task1還沒有運作,就不會被生效(例如:不設定屬性),如果你在随後配置它,你所作的一切都會被覆寫。

注意2:未來的Ant版本可能不會相容這裡所提的屬性,因為很有可能根本沒有task執行個體,隻有proxies。

3.4 Properties

一個project可以有很多的properties。可以在buildfile中用property task來設定,或在Ant之外設定。一個property有一個名字和一個值。property可用于task的屬性值。這是通過将屬性名放在"${"和"}"之間并放在屬性值的位置來實作的。例如如果有一個property builddir的值是"build",這個property就可用于屬性值:${builddir}/classes。這個值就可被解析為build/classes。

内置屬性

如果你使用了〈property〉 task 定義了所有的系統屬性,Ant允許你使用這些屬性。例如,${os.name}對應作業系統的名字。

要想得到系統屬性的清單可參考the Javadoc of System.getProperties。

除了Java的系統屬性,Ant還定義了一些自己的内置屬性:

basedir project基目錄的絕對路徑 (與〈project〉的basedir屬性一樣)。

ant.file buildfile的絕對路徑。

ant.version Ant的版本。

ant.project.name 目前執行的project的名字;由〈project〉的name屬性設定.

ant.java.version Ant檢測到的JVM的版本; 目前的值有"1.1", "1.2", "1.3" and "1.4".

例子

〈project name="MyProject" default="dist" basedir="."〉

〈!-- set global properties for this build --〉

〈property name="src" value="."/〉

〈property name="build" value="build"/〉

〈property name="dist" value="dist"/〉

〈target name="init"〉

〈!-- Create the time stamp --〉

〈tstamp/〉

〈!-- Create the build directory structure used by compile --〉

〈mkdir dir="${build}"/〉

〈/target〉

〈target name="compile" depends="init"〉

〈!-- Compile the java code from ${src} into ${build} --〉

〈javac srcdir="${src}" destdir="${build}"/〉

〈/target〉

〈target name="dist" depends="compile"〉

〈!-- Create the distribution directory --〉

〈mkdir dir="${dist}/lib"/〉

〈!-- Put everything in ${build} into the MyProject-${DSTAMP}.jar file --〉

〈jar jarfile="${dist}/lib/MyProject-${DSTAMP}.jar" basedir="${build}"/〉

〈/target〉

〈target name="clean"〉

〈!-- Delete the ${build} and ${dist} directory trees --〉

〈delete dir="${build}"/〉

〈delete dir="${dist}"/〉

〈/target〉

〈/project〉

3.5 Path-like Structures

你可以用":"和";"作為分隔符,指定類似PATH和CLASSPATH的引用。Ant會把分隔符轉換為目前系統所用的分隔符。

當需要指定類似路徑的值時,可以使用嵌套元素。一般的形式是

〈classpath〉

〈pathelement path="${classpath}"/〉

〈pathelement location="lib/helper.jar"/〉

〈/classpath〉

location屬性指定了相對于project基目錄的一個檔案和目錄,而path屬性接受逗号或分号分隔的一個位置清單。path屬性一般用作預定義的路徑--其他情況下,應該用多個location屬性。

為簡潔起見,classpath标簽支援自己的path和location屬性。是以:

〈classpath〉

〈pathelement path="${classpath}"/〉

〈/classpath〉

可以被簡寫作:

〈classpath path="${classpath}"/〉

也可通過〈fileset〉元素指定路徑。構成一個fileset的多個檔案加入path-like structure的順序是未定的。

〈classpath〉

〈pathelement path="${classpath}"/〉

〈fileset dir="lib"〉

〈include name="***.jar"/〉

〈/fileset〉

〈pathelement location="classes"/〉

〈/path〉

〈path id="tests.path"〉

〈path refid="base.path"/〉

〈pathelement location="testclasses"/〉

〈/path〉

前面所提的關于〈classpath〉的簡潔寫法對于〈path〉也是有效的,如:

〈path id="tests.path"〉

〈path refid="base.path"/〉

〈pathelement location="testclasses"/〉

〈/path〉

可寫成:

〈path id="base.path" path="${classpath}"/〉

指令行變量

有些task可接受參數,并将其傳遞給另一個程序。為了能在變量中包含空格字元,可使用嵌套的arg元素。

Attribute Description Required

value 一個指令行變量;可包含空格字元。 隻能用一個

line 空格分隔的指令行變量清單。

file 作為指令行變量的檔案名;會被檔案的絕對名替代。

path 一個作為單個指令行變量的path-like的字元串;或作為分隔符,Ant會将其轉變為特定平台的分隔符。

例子

〈arg value="-l -a"/〉

是一個含有空格的單個的指令行變量。

〈arg line="-l -a"/〉

是兩個空格分隔的指令行變量。

〈arg path="/dir;/dir2:/dir3"/〉

是一個指令行變量,其值在DOS系統上為/dir;/dir2;/dir3;在Unix系統上為/dir:/dir2:/dir3 。

References

buildfile元素的id屬性可用來引用這些元素。如果你需要一遍遍的複制相同的XML代碼塊,這一屬性就很有用--如多次使用〈classpath〉結構。

下面的例子:

〈project ... 〉

〈target ... 〉

〈rmic ...〉

〈classpath〉

〈pathelement location="lib/"/〉

〈pathelement path="${java.class.path}/"/〉

〈pathelement path="${additional.path}"/〉

〈/classpath〉

〈/rmic〉

〈/target〉

〈target ... 〉

〈javac ...〉

〈classpath〉

〈pathelement location="lib/"/〉

〈pathelement path="${java.class.path}/"/〉

〈pathelement path="${additional.path}"/〉

〈/classpath〉

〈/javac〉

〈/target〉

〈/project〉

可以寫成如下形式:

〈project ... 〉

〈path id="project.class.path"〉

〈pathelement location="lib/"/〉

〈pathelement path="${java.class.path}/"/〉

〈pathelement path="${additional.path}"/〉

〈/path〉

〈target ... 〉

〈rmic ...〉

〈classpath refid="project.class.path"/〉

〈/rmic〉

〈/target〉

〈target ... 〉

〈javac ...〉

〈classpath refid="project.class.path"/〉

〈/javac〉

〈/target〉

〈/project〉

所有使用PatternSets, FileSets 或 path-like structures嵌套元素的task也接受這種類型的引用。

4.1 File(Directory)類

4.1.1 Mkdir

? 建立一個目錄,如果他的父目錄不存在,也會被同時建立。

? 例子:

〈mkdir dir="build/classes"/〉

? 說明: 如果build不存在,也會被同時建立

4.1.2 Copy

? 拷貝一個(組)檔案、目錄

? 例子:

1. 拷貝單個的檔案:

〈copy file="myfile.txt" tofile="mycopy.txt"/〉

2. 拷貝單個的檔案到指定目錄下

〈copy file="myfile.txt" todir="../some/other/dir"/〉

3. 拷貝一個目錄到另外一個目錄下

〈copy todir="../new/dir"〉

〈fileset dir="src_dir"/〉

〈/copy〉

4. 拷貝一批檔案到指定目錄下

〈copy todir="../dest/dir"〉

〈fileset dir="src_dir"〉

〈exclude name="***.java"/〉

〈/copy〉

5. 拷貝一批檔案到指定目錄下,将檔案名後增加。Bak字尾

〈copy todir="../backup/dir"〉

〈fileset dir="src_dir"/〉

〈mapper type="glob" from="*" to="*.bak"/〉

〈/copy〉

6. 拷貝一組檔案到指定目錄下,替換其中的@标簽@内容

〈copy todir="../backup/dir"〉

〈fileset dir="src_dir"/〉

〈filterset〉

〈filter token="TITLE" value="Foo Bar"/〉

〈/filterset〉

〈/copy〉

4.1.3 Delete

? 删除一個(組)檔案或者目錄

? 例子

1. 删除一個檔案

〈delete file="/lib/ant.jar"/〉

2. 删除指定目錄及其子目錄

〈delete dir="lib"/〉

3. 删除指定的一組檔案

〈delete〉

〈fileset dir="." includes="***.jar"/〉

〈exclude name="**/ant.jar"/〉

〈/fileset〉

〈/move〉

5. 移動檔案過程中增加。Bak字尾

〈move todir="my/src/dir"〉

〈fileset dir="my/src/dir"〉

〈exclude name="**Test.class"

/〉

将${build}/classes下面的所有檔案打包到${dist}/lib/app.jar中,但是包括mypackage/test/所有檔案不包括所有的Test.class

3. 〈jar destfile="${dist}/lib/app.jar"

basedir="${build}/classes"

includes="mypackage/testTest.class"

manifest=”my.mf”

/〉

manifest屬性指定自己的META-INF/MANIFEST.MF檔案,而不是由系統生成

4.3.2 war

? 對Jar的擴充,用于打包Web應用

? 例子:

? 假設我們的檔案目錄如下:

thirdparty/libs/jdbc1.jar

thirdparty/libs/jdbc2.jar

build/main/com/myco/myapp/Servlet.class

src/metadata/myapp.xml

src/html/myapp/index.html

src/jsp/myapp/front.jsp

src/graphics/images/gifs/small/logo.gif

src/graphics/images/gifs/large/logo.gif

? 下面是我們的任務的内容:

〈war destfile="myapp.war" webxml="src/metadata/myapp.xml"〉

〈fileset dir="src/html/myapp"/〉

〈fileset dir="src/jsp/myapp"/〉

〈lib dir="thirdparty/libs"〉

〈exclude name="jdbc1.jar"/〉

〈/lib〉

〈classes dir="build/main"/〉

〈zipfileset dir="src/graphics/images/gifs"

prefix="images"/〉

〈/war〉

? 完成後的結果:

WEB-INF/web.xml

WEB-INF/lib/jdbc2.jar

WEB-INF/classes/com/myco/myapp/Servlet.class

META-INF/MANIFEST.MF

index.html

front.jsp

images/small/logo.gif

images/large/logo.gif

4.3.3 ear

? 用于打包企業應用

? 例子

〈ear destfile="${build.dir}/myapp.ear" appxml="${src.dir}/metadata/application.xml"〉

〈fileset dir="${build.dir}" includes="*.jar,*.war"/〉

〈/ear〉

4.4 時間戳

在生成環境中使用目前時間和日期,以某種方式标記某個生成任務的輸出,以便記錄它是何時生成的,這經常是可取的。這可能涉及編輯一個檔案,以便插入一個字元串來指定日期和時間,或将這個資訊合并到 JAR 或 zip 檔案的檔案名中。

這種需要是通過簡單但是非常有用的 tstamp 任務來解決的。這個任務通常在某次生成過程開始時調用,比如在一個 init 目标中。這個任務不需要屬性,許多情況下隻需 〈tstamp/〉 就足夠了。

tstamp 不産生任何輸出;相反,它根據目前系統時間和日期設定 Ant 屬性。下面是 tstamp 設定的一些屬性、對每個屬性的說明,以及這些屬性可被設定到的值的例子:

屬性 說明 例子

DSTAMP 設定為目前日期,預設格式為yyyymmdd 20031217

TSTAMP 設定為目前時間,預設格式為 hhmm 1603

TODAY 設定為目前日期,帶完整的月份 2003 年 12 月 17 日

例如,在前一小節中,我們按如下方式建立了一個 JAR 檔案:

〈jar destfile="package.jar" basedir="classes"/〉

在調用 tstamp 任務之後,我們能夠根據日期命名該 JAR 檔案,如下所示:

〈jar destfile="package-${DSTAMP}.jar" basedir="classes"/〉

是以,如果這個任務在 2003 年 12 月 17 日調用,該 JAR 檔案将被命名為 package-20031217.jar。

還可以配置 tstamp 任務來設定不同的屬性,應用一個目前時間之前或之後的時間偏移,或以不同的方式格式化該字元串。所有這些都是使用一個嵌套的 format 元素來完成的,如下所示:

〈tstamp〉

〈format property="OFFSET_TIME"

pattern="HH:mm:ss"

offset="10" unit="minute"/〉

〈/tstamp〉

上面的清單将 OFFSET_TIME 屬性設定為距離目前時間 10 分鐘之後的小時數、分鐘數和秒數。

用于定義格式字元串的字元與 java.text.SimpleDateFormat 類所定義的那些格式字元相同

4.5 執行SQL語句

? 通過jdbc執行SQL語句

? 例子:

1. 〈sql

driver="org.gjt.mm.mysql.Driver"

url="jdbc:mysql://localhost:3306/mydb"

userid="root"

password="root"

src="data.sql"

/〉

2. 〈sql

driver="org.database.jdbcDriver"

url="jdbc:database-url"

userid="sa"

password="pass"

src="data.sql"

rdbms="oracle"

version="8.1."

〈/sql〉

隻有在oracle、版本是8.1的時候才執行

4.6 發送郵件

? 使用SMTP伺服器發送郵件

? 例子:

〈mail mailhost="smtp.myisp.com" mailport="1025" subject="Test build"〉

〈from address="mailto:[email protected]〉

〈to address="mailto:[email protected]〉

〈message〉The ${buildname} nightly build has completed〈/message〉

〈fileset dir="dist"〉

〈includes name="***.jar"/>

        </fileset>

    </path>

    <filter token="year" value="${year}"/>

    <filter token="version" value="${version}"/>

    <filter token="date" value="${TODAY}"/>

    <filter token="log" value="true"/>

    <filter token="verbose" value="true"/>

</target>

<!-- =================================================================== -->

<!-- Help on usage                                                       -->

<!-- =================================================================== -->

<target name="usage" depends="init">

    <echo message="${Name} Build file"/>

    <echo message="-------------------------------------------------------------"/>

    <echo message=""/>

    <echo message=" available targets are:"/>

    <echo message=""/>

    <echo message="   jar      --> generates the ${name}.jar file"/>

    <echo message="   build    --> compiles the source code"/>

    <echo message="   javadoc --> generates the API documentation"/>

    <echo message="   clean    --> cleans up the directory"/>

    <echo message=""/>

    <echo message=" Please rename build.properties.default to build.properties"/>

    <echo message=" and edit build.properties to specify JSDK 2.3 classpath."/>

    <echo message=""/>

    <echo message=" See the comments inside the build.xml file for more details."/>

    <echo message="-------------------------------------------------------------"/>

    <echo message=""/>

    <echo message=""/>

</target>

<!-- =================================================================== -->

<!-- Prepares the source code                                            -->

<!-- =================================================================== -->

<target name="prepare-src" depends="init">

    <!-- create directories -->

    <mkdir dir="${build.src}"/>

    <mkdir dir="${build.dest}"/>

    <!-- copy src files -->

    <copy todir="${build.src}">

      <fileset dir="${src.dir}"/>

    </copy>

</target>

<!-- =================================================================== -->

<!-- Compiles the source directory                                       -->

<!-- =================================================================== -->

<target name="build" depends="prepare-src">

    <javac srcdir="${build.src}"

           destdir="${build.dest}"

           debug="${debug}"

           optimize="${optimize}">

      <classpath refid="classpath"/>

    </javac>

</target>

<!-- =================================================================== -->

<!-- Creates the class package                                           -->

<!-- =================================================================== -->

<target name="jar" depends="build">

    <jar jarfile="${lib.dir}/${name}.jar"

         basedir="${build.dest}"

         includes="**"/>

</target>

<!-- =================================================================== -->

<!-- Creates the API documentation                                       -->

<!-- =================================================================== -->

<target name="javadoc" depends="build">

    <mkdir dir="${build.javadocs}"/>

    <javadoc packagenames="${packages}"

             sourcepath="${build.src}"

             destdir="${build.javadocs}"

             author="true"

             version="true"

             use="true"

             splitindex="true"

             windowtitle="${Name} API"

             doctitle="${Name}">

      <classpath refid="classpath"/>

    </javadoc>

</target>

<!-- =================================================================== -->

<!-- Clean targets                                                       -->

<!-- =================================================================== -->

<target name="clean" depends="init">

    <delete dir="${build.src}"/>

    <delete dir="${build.dest}/org"/>

    <delete dir="${build.dest}/com"/>

    <delete>

      <fileset dir="${build.dest}" includes="***.jar"/>

        </fileset>

    </path>

  則相當于設定了:CLASSPATH=/path/to/resin/lib/jsdk23.jar;/path/to/project/lib*.class"/>

    </delete>

</target>

  TODO:

  更多任務/擴充:(樣例)

  測試任務:JUnit測試

  代碼風格檢查任務:CheckStyle,Jalopy等

  郵件警報任務:可以把以上這些任務的輸出警告發送到制定的使用者清單中,這個任務可以設定每天自動運作。