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

问题描述 投票:0回答:2

我想更新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 properties exec ant-contrib
2个回答
0
投票

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

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

示例嵌入式groovy脚本:


0
投票

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

<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>
© www.soinside.com 2019 - 2024. All rights reserved.