ant build file 用於 java 自動運行腳本相似於linux 的bash 和 windows dos script. 經常使用於自動deploy war ear file to server.html
ant 是基於xml file 經過tag 命令執行java
一個build.xml 至少包含project and target taglinux
ant build file at least has one <project> <target>windows
<project> require
attributes: name default basedirbash
<target> require
attributes: name depends?????? <target name='test' depends='package,compile'eclipse
<echo> print the msg out on consoleide
######### build file 匹配模式ui
patternspa
? - Matches one character only..net
* - Matches zero or many characters.
** - Matches zero or many directories recursively.
######經常使用標籤
########<property tag>
<property> define variable
###default properties
ant.file The full location of the build file.
ant.version The version of the Apache Ant installation.
basedir The basedir of the build, as specified in the basedir attribute of the project element.
ant.java.version The version of the JDK that is used by Ant.
ant.project.name The name of the project, as specified in the name atrribute of the project element.
ant.project.default-target The default target of the current project.
ant.project.invoked-targets Comma separated list of the targets that were invoked in the current project.
ant.core.lib The full location of the Ant jar file.
ant.home The home directory of Ant installation.
ant.library.dir The home directory for Ant library files - typically ANT_HOME/lib folder.
<property> tag 能夠定義在build file 爲了可維護和提升代碼robust 能夠將一些屬性定義在build.properties 文件裏面。 經過 <property file="build.properties"> 引用build.properties 的內容。
#### <fileset> 指定文件夾下選擇須要的文件。 include tag 表示包含經過pattern 來選擇 excluude 就是排除哪些文件
<fileset> collection of files
<fileset dir="${src}" casesensitive="yes">
<include name="**/*.java"/>
<exclude name="**/*Stub*"/>
</fileset>
<path> 就是一個路徑集合 在<path> 下經過<pathelement 說明具體路徑 其中location 路徑屬性是特指具體某一個路徑 path 屬性是泛指 能夠是一個path 或者 path list
<path id="test.classpath">
<pathelement path="c:/java/jdk1.7.0/jre/lib"></pathelement>
<pathelement location="C:/eclipse 4.2/plugins/org.junit_4.10.0.v4_10_0_v20120426-0900/junit.jar"></pathelement>
<pathelement location="C:/eclipse 4.2/plugins/org.hamcrest.core_1.1.0.v20090501071000.jar"></pathelement>
</path>
####<javac> compile
<javac destdir="${class.dir}" >
<src refid="compilejava"></src>
<classpath refid="test.classpath"></classpath>
</javac>
<jar destfile="${libs}/ant.jar" basedir="${class.dir}">
</jar>
補充鏈接詳細例子和部分tags
http://blog.csdn.net/yangdayin/article/details/7681567
http://www.cnblogs.com/xionghui/archive/2012/03/13/2393679.html