7

ファイル(パターンで指定)をAntmacrodefの特定の場所に移動しようとしています。

<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_name}これは、不変であるため、一度だけ機能します。

オプションは変数タスクを使用することですが、refidをに割り当てる方法が見つかりませんでしたvar

macrodefにローカル変数に似たものを含める方法はありますか?または(XY問題)私の問題を解決するためのより良い方法はありますか?

4

1 に答える 1

11

localAnt 1.8 以降、このタスクを使用できます。例えば:

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

あなたの例はまさにそのようなものlocalです!

于 2011-11-28T07:17:24.337 に答える