ant脚本的一些使用
来源:互联网 发布:徐州管家婆软件 编辑:程序博客网 时间:2024/06/12 13:43
参考:
http://blog.csdn.net/yieryi_/article/details/48877677
http://blog.csdn.net/caolaosanahnu/article/details/7886290
1.macrodef
ant脚本的宏,macrodef和target平级,target可以调用macrodef,而macrodef不可以调用target。
用法:
<macrodef name="hong">
<attribute name="bianliang"/>
<attribute name="bianliang2"/>
<echo message="@{bianliang}"/>
<echo message="@{bianliang2}"/>
</macrodef>
其中attribute定义宏中使用的变量,使用的时候用@,而不是$,在target中调用如下。
<target name="diaoyong">
<hong bianliang="11" bianliang2="22"/>
</target>
其中target可以通过宏的名字直接调用,通过attribute中的name来设定其值。
2.判断是否存在
Available判断某个类、文件、路径是否存在
1)判断某个类是否存在
<available property="class.exist" classname="package.test" classpath="dist/test.jar"/>
2)判断某个文件是否存在
<available property="file.exist" file="test.txt" filepath="src/test" type="file"/>
3)判断某个目录是否存在
<available property="file.exist" file="dirname" filepath="src/test" type="dir"/>
4)判断某个资源是否存在
<available property="resource.exist" resource="package/test/test.class" classpath="dist/test.jar"/>
3.判断文件是否存在
需要在ant的lib包中引入ant-contrib.jar
使用该jar包有两种方式
1)
<taskdef resource="net/sf/antcontrib/antcontrib.properties"/>
2)把ant-contrib.jar copy到一个相对独立的目录下,但是你在用的时候一定要指定这个目录,以便于ant能找到它
<taskdef resource="net/sf/antcontrib/antcontrib.properties">
<classpath>
<pathelement location="D:/ant-contrib/ant-contrib-1.0b2.jar"/>
</classpath>
</taskdef>
<avaliable property="isExist" file="src/test"/>
<if>
<isset property="isExist"/>
<then>
<copy todir="a1/test" preservelastmodified="true">
<fileset dir="a2/test"/>
</copy>
</then>
<else>
<echo message="不存在"/>
</else>
</if>
4.antcontib参考地址
http://ant-contrib.sourceforge.net/ant-contrib/manual/tasks/index.html
- ant脚本的一些使用
- ant脚本的一些总结
- Ant脚本的使用
- 使用 Ant 编写自动化的 telnet 脚本
- 构建脚本ivy、ant的使用
- 使用Ant脚本打包
- Ant脚本初使用
- Ant“蚂蚁"的一些使用小结
- Ant使用的一些细节知识
- ant 打包等一些命令的使用
- Jibx 结合 ant使用的一些心得
- ant脚本的介绍
- 根据xsd使用xmlbean生成代码的ant脚本
- ant的一些技巧!
- ant的一些知识
- ANT的一些用法
- Ant的一些知识
- ANT的一些操作
- S5P4418 android 5.1 EC20 R2.0 PCIE接口调试记录
- lintcode刷题(python)--排列组合
- RSA算法原理(一)
- MySQL
- Java反射机制详解
- ant脚本的一些使用
- JS中位置与大小的获取方法
- 二维码生成
- 贪心算法求最短路径,用Python实现
- C# 图灵机器人
- 使用JavaScript实现单击复选框实现全选与全不选功能并通过ajax实现批量删除功能
- Java数据类型
- java 检测class文件走哪个jar包的代码
- AndroidManifest合并原理