ANT basic

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

相关文章
相关标签/搜索