如何覆盖 Ant 中的属性? [英] How to over-write the property in Ant?

查看:25
本文介绍了如何覆盖 Ant 中的属性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法为 Ant property 任务重新分配值?或者还有其他可用的任务吗?

Is there a way to re-assign the value for the Ant property task? Or is there another task available for that purpose?

推荐答案

根据你想如何使用修改后的属性,你可以使用macrodefs.

Depending on how you want to use the modified property, you can use macrodefs.

例如,而不是编写以下内容:

For example, instead of writing the following:

<target name="foo">
   <echo message="${my_property}"/>
</target>

并且不能用另一条消息调用 ant foo,你可以写:

and not being able to call ant foo with another message, you could write:

<macrodef name="myecho">
    <attribute name="msg"/>
    <sequential>
        <echo message="@{msg}"/>
    </sequential>
</macrodef>

<target name="foo">
   <myecho msg="${my_property}"/>
   <property name="my_property2" value="..."/>
   <myecho msg="${my_property2}"/>
</target>

这篇关于如何覆盖 Ant 中的属性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆