Ant 宏定义和;本地物业“;

Ant 宏定义和;本地物业“;,ant,macrodef,Ant,Macrodef,我正在尝试将文件(由模式指定)移动到Ant macrodef中的给定位置: <macrodef name="extract"> <attribute name="package"/> <sequential> <!-- the path will contain the unique file in extracted regardless of the name --> <path id=

我正在尝试将文件(由模式指定)移动到Ant macrodef中的给定位置:

<macrodef name="extract">
    <attribute name="package"/> 
    <sequential>

        <!-- the path will contain the unique file in extracted regardless of the name -->
        <path id="source_refid">
            <dirset dir="${dep}/lib/@{package}/extracted/">
                <include name="@{package}-*"/>
            </dirset>
        </path>

        <!-- this is not working: properties are immutable -->
        <property name="source_name" refid="source_refid"/>

        <move
            file="${source_name}"
            tofile="${dep}/@{package}/"
            overwrite="true"
        />

    </sequential>
</macrodef>

因为
${source\u name}
是不可变的,所以这只工作一次

一个选项是使用变量任务,但我没有找到将refid分配给
var
的方法


有没有办法在宏定义中包含类似于局部变量的内容?或者(XY问题)有没有更好的方法来解决我的问题?

因为Ant 1.8可以使用。例如:

<local name="source_name"/>
<property name="source_name" refid="source_refid"/>

你的例子正是
local
所适用的那种东西