Search code examples
antant-contrib

antcall in foreach is not executing loop


I want to build couple of projects based on no of .composites by using ant scripts. i added all the taskref tags,lib path every thing in my build.xml file. i wrote the following piece of code for the same and i am getting the error foreach doesn't support the nested "antcall" element.

<target name="createApplicationDAA">
<foreach param="program">
    <path>
        <fileset dir="${soaProjectName}/Composites" includes="**/*.composite"/>
    </path>
    <antcall target="createDAA"/>
</foreach>
</target>
<target name="createDAA">
..........
....
</target>

clearly, my requirement is to create all DAAs by building all the composites by using foreach or for loop in ant script. can anybody please let me know,where am i doing wrong?


Solution

  • foreach doesn't use nested elements to determine what to run, it takes a target attribute:

    <target name="createApplicationDAA">
      <foreach param="program" target="createDAA">
        <path>
          <fileset dir="${soaProjectName}/Composites" includes="**/*.composite"/>
        </path>
      </foreach>
    </target>
    <target name="createDAA">
      <echo>${program}</echo>
    </target>
    

    Alternatively, use <for>, which takes a nested <sequential>

    <target name="createApplicationDAA">
      <for param="program">
        <path>
          <fileset dir="${soaProjectName}/Composites" includes="**/*.composite"/>
        </path>
        <sequential>
          <echo>@{program}</echo>
        </sequential>
      </for>
    </target>