antpropertiesexecant-contrib

How to change value of outputproperty in a for loop in ant script for an exec tast


I am trying to update ant script where I want to get new output in outputproperty of and exec task. below is my ant script.

<target name="print_process_list">
    <echo message="print_process_list start"/>
    <echo message="${compile_project_lists} "/>
    <echo message="print_process_list end"/>
</target>
<target name="buildall" depends="print_process_list">
    <ac:for list="${compile_project_lists}" param="iprocess">
            <sequential>
            <exec executable="./ant_xml_pars.sh" outputproperty="ant_parstout" failonerror="false" >
                                    <arg value="@{iprocess}"/>
                            </exec>
                            <echo message="${ant_parstout} " />
        </sequential>
    </ac:for>

ant_xml_pars.sh gives output based on iprocess passed from the list. ant_parstout takes the first iteration output. but its value does not change for later iterations in the loop. My requirement is to get the output in ant_parstout based on the process passed as argument. I tried macrodef but not success.


Solution

  • I suggest reading the ant-contrib documentation and use the variable task instead of an ANT property.

    ANT is not a programming language as evidenced by the fact that properties in ANT are immutable. To work around these limitations some people use the ant-contrib extension to ANT, adding tasks like "for". Personally I favour embedding scripts within ANT rather that trying to program a loop in XML...

    Example embedded groovy script: