ant control statements
来源:互联网 发布:淘宝网完美芦荟胶 编辑:程序博客网 时间:2024/05/21 10:46
Loop
The 'loop' task required ant-contrib package, please download from
http://ncu.dl.sourceforge.net/project/ant-contrib/ant-contrib/1.0b3/ant-contrib-1.0b3-bin.zip
Loop all .txt file in a folder, and take action on each file
<taskdef name="for" classname="net.sf.antcontrib.logic.ForTask" classpath="${lib.dir}/lib/ant-contrib-1.0b3.jar" /> <target name="loopfolder"> <for param="filename"> <path>=> <fileset dir="${folder}" excludes="test.txt" includes="*.txt" /> </path> <sequential> <echo message="@{filename}"/> </sequential> </for> </target>
Call Another Target
<taskdef name="for" classname="net.sf.antcontrib.logic.ForTask" classpath="${lib.dir}/lib/ant-contrib-1.0b3.jar" /> <target name="loopfolder"> <for param="filename"> <path>=> <fileset dir="${folder}" excludes="test.txt" includes="*.txt" /> </path> <sequential> <echo message="@{filename}"/> <antcall target="fileaction"/> </sequential> </for> </target> <target name="fileaction"> <property name="infile" value="${data.dir}/demo.txt"/> <echo message="${infile}"/> </target>
Call Another Target with parameters passing
<taskdef name="for" classname="net.sf.antcontrib.logic.ForTask" classpath="${lib.dir}/lib/ant-contrib-1.0b3.jar" /> <target name="loopfolder"> <for param="filename"> <path>=> <fileset dir="${folder}" excludes="test.txt" includes="*.txt" /> </path> <sequential> <echo message="@{filename}"/> <antcall target="fileaction"> <param name="infile" value="@{filename}"/> </antcall> </sequential> </for> </target> <target name="fileaction"> <property name="infile" value="${data.dir}/demo.txt"/> <echo message="${infile}"/> </target>
If-Then-Else
The 'if' task required ant-contrib package, please refer to 'Loop' task
<taskdef name="if" classname="net.sf.antcontrib.logic.IfTask" classpath="${lib.dir}/lib/ant-contrib-1.0b3.jar" /> <if> <filesmatch file1="${infile}" file2="${outfile}"/> <then> <echo message="File ${infile} and file ${outfile} are same" /> </then> <else> <echo message="WARNING: File ${infile} and file ${outfile} are same" /> </else> </if>
Failed a build
<taskdef name="if" classname="net.sf.antcontrib.logic.IfTask" classpath="${lib.dir}/lib/ant-contrib-1.0b3.jar" /> <if> <filesmatch file1="${infile}" file2="${outfile}"/> <then> <echo message="File ${infile} and file ${outfile} are same" /> </then> <else> <fail message="Build failed because file ${infile} and file ${outfile} are not matched." /> </if>
ant.project.name
This is global project name, its value is define in 'project' element.
<project name="TestProject" default="compile" basedir="."> <property name="yourprojectname" value="${ant.project.name}"/> ...</project>
0 0
- ant control statements
- [Ant]Tomcat control target
- Control Statements of Java -from The Complete Reference Java
- 4.2.1 - Flow Control Using If/Else Statements
- Octave /Matlab--Control Statements:for,while, if statement----Coursera ML笔记
- 8.6 Statements
- 15. Statements
- Understanding Statements
- TAAL1 Statements
- socket,statements
- 5-Statements
- C# Statements
- Assert statements
- Control
- Control
- Control
- Control
- ant
- 如何获取自定义属性
- parse generator生成c++文件
- JavaScript入门<3>JSON
- java函数定义泛型
- Java String,StringBuilder,StringBuffer区别和实际应用总结
- ant control statements
- PyQt学习笔记(4)--Smart Dialog
- 视音频基础知识——YUV420
- 各种C++关键字的作用
- java static 详解
- 11.15
- 网易等一些大型网站在首页 有不同信息,现在如何看深圳 北京 上海的 网易服务器信息版本?
- Android开发——理解文件存储
- JAVA入门基础详解之二