如何在exe脚本的ant脚本中更改for循环中outputproperty的值

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了如何在exe脚本的ant脚本中更改for循环中outputproperty的值相关的知识,希望对你有一定的参考价值。

我想更新ant脚本,我想在outputproperty和exec任务中获得新的输出。下面是我的蚂蚁脚本。

<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根据从列表传递的iprocess给出输出。 ant_parstout接受第一次迭代输出。但是它的值不会因循环中的后续迭代而改变。我的要求是根据作为参数传递的进程获取ant_parstout中的输出。我试过macrodef但没有成功。

答案

我建议阅读ant-contrib文档并使用variable任务而不是ANT属性。

ANT不是一种编程语言,因为ANT中的属性是immutable。为了解决这些限制,一些人使用ant-contrib扩展到ANT,添加“for”之类的任务。我个人赞成在ANT中嵌入脚本而不是尝试用XML编写循环...

示例嵌入式groovy脚本:

另一答案

这篇文章有点旧,但我遇到了同样的问题,所以这就是我所做的:

<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.@{iprocess}" failonerror="false" >
                                    <arg value="@{iprocess}"/>
                            </exec>
                            <echo message="${ant_parstout.@{iprocess}} " />
        </sequential>
    </ac:for>

以上是关于如何在exe脚本的ant脚本中更改for循环中outputproperty的值的主要内容,如果未能解决你的问题,请参考以下文章

shell编程中的for循环如何实现

ant脚本的一些总结

如何在带有 for 循环的 bash 脚本中使用标志?

在 bash 脚本中,如何引用单独的文件以在 for 循环中使用它? [复制]

如何在 javascript 脚本标签中使用 razor for 循环?

减少咖啡脚本中的循环