| 1 | <project default="invalid"> |
| 2 | <target name="invalid"> |
| 3 | <fail>Don't call this file directly.</fail> |
| 4 | </target> |
| 5 | |
| 6 | <target name="setup"> |
| 7 | <taskdef resource="net/sf/antcontrib/antcontrib.properties"> |
| 8 | <classpath location="${antcontrib.jar}"/> |
| 9 | </taskdef> |
| 10 | </target> |
| 11 | |
| 12 | <target name="teardown"> |
| 13 | <delete dir="foreachtest"/> |
| 14 | </target> |
| 15 | |
| 16 | <target name="echo"> |
| 17 | <echo>Called with param: ${param}</echo> |
| 18 | </target> |
| 19 | |
| 20 | <target name="convert-bar" unless="param"> |
| 21 | <property name="param" refid="bar"/> |
| 22 | </target> |
| 23 | |
| 24 | <target name="echoFilename" depends="convert-bar"> |
| 25 | <basename file="${param}" property="param2"/> |
| 26 | <echo>Called with param: ${param2}</echo> |
| 27 | </target> |
| 28 | |
| 29 | <target name="simpleList" depends="setup"> |
| 30 | <foreach list="1,2,3" target="echo" param="param"/> |
| 31 | </target> |
| 32 | |
| 33 | <target name="delimiter" depends="setup"> |
| 34 | <foreach list="1/2/3" target="echo" param="param" delimiter="/"/> |
| 35 | </target> |
| 36 | |
| 37 | <target name="fileset" depends="setup"> |
| 38 | <mkdir dir="foreachtest"/> |
| 39 | <touch file="foreachtest/1"/> |
| 40 | <touch file="foreachtest/2"/> |
| 41 | <touch file="foreachtest/3"/> |
| 42 | <foreach target="echoFilename" param="param"> |
| 43 | <fileset dir="foreachtest"/> |
| 44 | </foreach> |
| 45 | </target> |
| 46 | |
| 47 | <target name="filesetAndList" depends="setup"> |
| 48 | <mkdir dir="foreachtest"/> |
| 49 | <touch file="foreachtest/3"/> |
| 50 | <foreach list="1,2" target="echoFilename" param="param"> |
| 51 | <fileset dir="foreachtest"/> |
| 52 | </foreach> |
| 53 | </target> |
| 54 | |
| 55 | <target name="noList" depends="setup"> |
| 56 | <foreach target="echo" param="param"/> |
| 57 | </target> |
| 58 | |
| 59 | <target name="noTarget" depends="setup"> |
| 60 | <foreach list="1,2,3" param="param"/> |
| 61 | </target> |
| 62 | |
| 63 | <target name="noParam" depends="setup"> |
| 64 | <foreach list="1,2,3" target="echo"/> |
| 65 | </target> |
| 66 | |
| 67 | <target name="nestedParam" depends="setup"> |
| 68 | <foreach list="1" target="echo" param="who-cares"> |
| 69 | <param name="param" value="rincewind"/> |
| 70 | </foreach> |
| 71 | </target> |
| 72 | |
| 73 | <target name="nestedReference" depends="setup"> |
| 74 | <path id="foo"> |
| 75 | <pathelement location="twoflower"/> |
| 76 | </path> |
| 77 | <foreach list="1" target="echoFilename" param="who-cares"> |
| 78 | <reference refid="foo" torefid="bar"/> |
| 79 | </foreach> |
| 80 | </target> |
| 81 | |
| 82 | <target name="path" depends="setup"> |
| 83 | <mkdir dir="foreachtest"/> |
| 84 | <touch file="foreachtest/1"/> |
| 85 | <touch file="foreachtest/2"/> |
| 86 | <touch file="foreachtest/3"/> |
| 87 | <foreach target="echoFilename" param="param"> |
| 88 | <path> |
| 89 | <fileset dir="foreachtest"/> |
| 90 | </path> |
| 91 | </foreach> |
| 92 | </target> |
| 93 | |
| 94 | <target name="pathAndList" depends="setup"> |
| 95 | <mkdir dir="foreachtest"/> |
| 96 | <touch file="foreachtest/3"/> |
| 97 | <foreach list="1,2" target="echoFilename" param="param"> |
| 98 | <path> |
| 99 | <fileset dir="foreachtest"/> |
| 100 | </path> |
| 101 | </foreach> |
| 102 | </target> |
| 103 | |
| 104 | </project> |