<!--?xml version=
"1.0"
encoding=
"UTF-8"
-->
<project basedir=
"."
default
=
"foreachtest"
>
<property location=
"/usr/apache-ant/lib/ant-contrib-1.0b3.jar"
name=
"ant-contrib.jar"
>
<taskdef classpath=
"${ant-contrib.jar}"
resource=
"net/sf/antcontrib/antcontrib.properties"
>
<!-- ################ foreach test ########################## -->
<target name=
"loop"
>
<echo> ${file.name} </echo>
</target>
<!-- 把paths中的文件名循环作为参数传给loop -->
<target name=
"foreachtesta"
>
<foreach delimiter=
","
list=
""
param=
"file.name"
target=
"loop"
>
<path location=
"./"
>
<fileset dir=
"."
includes=
"*"
>
</fileset></path>
</foreach>
</target>
<target name=
"foreachtestc"
>
<!-- fileset is deprecated -->
<foreach delimiter=
","
list=
""
param=
"file.name"
target=
"loop"
>
<fileset dir=
"."
includes=
"*"
>
</fileset></foreach>
</target>
<!-- 把list中的数循环传给 number-->
<target name=
"foreachtestb"
>
<foreach delimiter=
","
list=
"1,2,3,6,5"
param=
"number"
target=
"number"
>
</foreach>
</target>
<target name=
"number"
>
<echo> ${number} </echo>
</target>
<!-- ################
if
test ########################## -->
<property name=
"display"
value=
"aa"
>
<target name=
"iftest"
>
<
if
>
<equals arg1=
"aa"
arg2=
"${display}"
>
<then>
<echo>aa</echo>
<!-- 若符合判断条件,即条件成功,使用antcall命令来执行某个target -->
</antcall></then>
<elseif>
<equals arg1=
"bb"
arg2=
"${display}"
>
<then>
<echo>bb</echo>
</then>
</equals></elseif>
<
else
>
<echo>
else
</echo>
</
else
>
</equals></
if
>
</target>
<target name=
"calltarget"
>
<echo>call</echo>
</target>
<!-- ################
for
test (未解决:failed to create task or type
for
) ########################### -->
<target name=
"fortest"
>
<
for
list=
"1,2"
param=
"number"
>
<sequential>
<!-- <
for
> makes use of ant's macrodef task, so the @{www.a6qp.com} notation is used
for
parameter substition -->
<echo>@{number}</echo>
</sequential>
<!-- sequential 循环体,可写多个 -->
<sequential>
<echo>other@{number}</echo>
</sequential>
</
for
>
</target>
</property></taskdef></property></project>