ant的一些核心任务;
1.
basename
Sets a property to the last element of a specified path in an effort to determine a file's name without directory structure
2.
dirname
Assigns a file's directory path to a property
3.
input
Displays a message and reads a line of input from the console, allowing for user input during the build process
4.
import
Allows the use of other Ant files
5.
record
Runs a listener that records the logging output of the build process to a file
6.
sequential
A container task that can contain other Ant tasks and run them in sequence
7.
rmic
Invokes the rmic compiler
8.
subant
Runs Ant within all subdirectories of the project directory
9.
tstamp
Sets time-based properties to the current time
10.
Ant has some additional Ant-specific properties:
ant.file
Contains the absolute path of the build file
ant.java.version
Contains the JVM version Ant is using (can hold only 1.1, 1.2, 1.3, 1.4 and [as of Ant 1.6] 1.5)
ant.project.name
Holds the name of the project that is executing (set with the name attribute of project)
ant.version
Contains the version of Ant running
basedir
Holds the absolute path of the project's base directory (set with the basedir attribute of project)
=======================
摘抄自 java development with ant
ant-contrlib的一些task,觉得可能有用的
1.
propertycopy,感觉有点像赋值,但是不是简单的赋值
<target name="propertycopy">
<property name="X" value="Y"/>
<property name="Y" value="Z"/>
<propertycopy name="A" from="${X}"/>
<echo message="A = ${A}"/>
</target>
The value of ${X} is “Y”. The from attribute of <propertycopy> refers to an Ant
property name, “Y” in this example. The value of the property Y is “Z”, so the output
is “A = Z”. This is a much nicer alternative than using the refid tricks.
2.osfamily 和操作系统相关的
<target name="osfamily">
<osfamily property="os.family" />
<echo message="O/S family is ${os.family}"/>
<property file="${os.family}.properties"/>
</target>
Executing this target on a Windows 2000 machine would load windows.properties.
Loading properties based on operating system family, or by hostname, enables build
files to adapt easily to their operating environment.
3.
Using if/then/else logic 逻辑判断,觉得会用到
<target name="if">
<if>
<equals arg1="${foo}" arg2="bar" />
<then>
<echo message="The value of property foo is bar" />
</then>
<else>
<echo message="The value of property foo is not bar" />
</else>
</if>
</target>
4.
Multiple value switching 开关控制
<target name="switch">
<switch value="${foo}">
<case value="bar">
<echo message="The value of property foo is bar" />
</case>
<case value="baz">
<echo message="The value of property foo is baz" />
</case>
<default>
<echo message="The value of property foo is not sensible" />
</default>
</switch>
</target>
5.
Catching task exceptions 使用try catch,不知道用处有多大
<target name="trycatch">
<trycatch property="exception.message"
reference="exception.ref">
<try>
<fail>Oops!</fail>
</try>
<catch>
<echo>Caught</echo>
</catch>
<finally>
<echo>Finally</echo>
</finally>
</trycatch>
<echo>As property: ${exception.message}</echo>
<property name="exception.value" refid="exception.ref" />
<echo>From reference: ${exception.value}</echo>
</target>
.....
Executing this target produces this output:
trycatch:
[trycatch] Caught exception: Oops!
[echo] Caught
[echo] Finally
[echo] As property: Oops!
[echo] From reference: C:\AntBook\Sections\Applying\tasks\
ant-contrib.xml:72: Oops!
BUILD SUCCESSFUL
6.
Using explicit iteration ,我一般使用for, 不知道为什么,这个应该还有点用处的吧
<target name="for-each">
<foreach list="1,2,3" target="loop" param="var"
delimiter=",">
<fileset dir="."/>
</foreach>
</target>
<target name="loop">
<echo message="var = ${var}"/>
</target>
...
out put is
for-each:
loop:
[echo] var = 1
loop:
[echo] var = 2
loop:
[echo] var = 3
loop:
[echo] var = C:\AntBook\Sections\Applying\tasks\ant-contrib.xml
loop:
[echo] var = C:\AntBook\Sections\Applying\tasks\build\build.properties
.
.
The target is invoked for each iteration by using the underlying mechanism that the
<antcall> task uses, which means that the dependencies of the target are reevaluated
each iteration.
分享到:
- 2008-04-16 21:38
- 浏览 18692
- 评论(2)
- 论坛回复 / 浏览 (2 / 3690)
- 查看更多
相关推荐
ant ant ant antant ant ant antant ant ant ant
ANT的常用标签练习,导入即可运行。有自定义标签
该程序为Ant的扩展任务,在拷贝文本格式的文件的同时替换文件中的Ant表达式,类似于 ${property.name},属性值来自于Ant脚本加载的属性文件,如果没有属性文件中没有定义相关属性,那么保留原来的表达式;...
一些常用到的电子书籍-Ant
ant ant下载 ant配置ant ant下载 ant配置ant ant下载 ant配置
ant开发指南用于说明ant一些相关信息
三.Ant的常用任务 四.利用Ant构建和部署Java工程 1.利用Ant的javac任务来编译java程序 2.使用Ant的java任务运行Java程序 3.使用Ant的jar任务生成jar文件 4.使用Ant的war任务打包J2EE Web项目 五.总结
[北京圣思园Ant深入详解]_003.Ant目标深度详解、使用Ant的各种任务
ant配置ant配ant配置ant配置置
开发工具 ant-1.9.6开发工具 ant-1.9.6开发工具 ant-1.9.6开发工具 ant-1.9.6开发工具 ant-1.9.6开发工具 ant-1.9.6开发工具 ant-1.9.6开发工具 ant-1.9.6开发工具 ant-1.9.6开发工具 ant-1.9.6开发工具 ant-1.9.6...
1,什么是ant ant是构建工具 2,什么是构建 概念到处可查到,形象来说,你要把...功能强大--ant能做的事情很多,可能你用了很久,你仍然不知道它能有多少功能。当你自己开发一些ant插件的时候,你会发现它更多的功能。
ant 讲解ant 讲解ant 讲解ant 讲解ant 讲解ant 讲解ant 讲解ant 讲解ant 讲解ant 讲解ant 讲解ant 讲解ant 讲解ant 讲解ant 讲解ant 讲解
Coverity 8.7.1 命令与 Ant 任务说明书 包括Coverity Analysis、Coverity Platform 和 Coverity Desktop 说明 如果你想对cov-analyze,cov-build,cov-run-desktop 等等有关coverity命令用法有更多了解的话,可以...
ant 的自定义任务,自己总结的,觉得比较设和初学者
ANT COLONY ANT COLONY ANT COLONY ANT COLONY ANT COLONY ANT COLONY ANT COLONY ANT COLONY ANT COLONY
[北京圣思园Ant深入详解]_004.实现自定义Ant任务
org.apache.tools.ant.Main org.apache.tools.ant.Task org.apache.tools.bzip2.CRC org.apache.tools.ant.Target org.apache.tools.ant.Project org.apache.tools.zip.ZipFile org.apache.tools.zip.ZipLong ...
ANT文件详解 ant介绍 ANT 命令
解决Eclipse+Ant启动任务失败的问题,在Eclipse中Windows->Preferences->Ant->Runtime->Classpath->Global Entries中加入即可
NULL 博文链接:https://weigang-gao.iteye.com/blog/2191184