8

I would like to understand that is the following possible in Ant

  • Read a property eg : ${for.loop.condition}

  • Based on the above property value , create a for loop

  • And loop dynamically create a string from that value

I have read on the ant-contrib task , but not so sure whether that would help me out.

Any examples would help me

AlBlue
  • 23,254
  • 14
  • 71
  • 91
Vivek
  • 2,091
  • 11
  • 46
  • 61

2 Answers2

5

You can use a variable where a list of values are concatenated to control the iteration, so you can decide what to do with each value. Check this post it may help you to use the "for" tag.

You can also use the for-each tag to iterate through a set of values selected with a fileset tag.

<foreach target="target2Call" param="paramName">
   <fileset dir="${myDir}">
       <include name="**/mifilesFilter.*" />
   </fileset>
</foreach>

Here's another example about how to use foreach tag.

Community
  • 1
  • 1
kothvandir
  • 2,111
  • 2
  • 19
  • 34
2

Hi you can use if and for loop like this :

<target name="mTomcat">
  <property name="property" value="xyz"/>                      
  <sequential>

  <if>
    <equals arg1="${property}" arg2="xyz" />
    <then>

      <for list="${list}" param="param" delimiter=",">
        <sequential>
            < do the stuff here with param >
       </sequential>
     </for>
  </sequential>
</target>
Sujith
  • 1,349
  • 1
  • 7
  • 12
  • @YaP The original poster mentions ant-contrib which adds a for command. http://ant-contrib.sourceforge.net/tasks/tasks/for.html – Raystorm May 14 '15 at 18:32