1

あるターゲットでAntファイルの「変数」を変更し、別のターゲットでその変更を確認したいと思います。

<variable name="foo" value="hello" />
<target name="print-me">
    <echo message="${foo}" />
    <antcall target="change-me" />
    <echo message="${foo}" />
</target>

<target name="change-me">
    <variable name="foo" value="world" />
</target>

「hello、world」を出力したいのですが、「hello、hello」を出力します。

4

2 に答える 2

2

どちらかを使用:

<target name="change-me">
    <variable name="foo" unset="true"/>
    <variable name="foo" value="world"/>
</target>

Oers があなたの質問へのコメントで既に述べたように、またはAnt アドオン Flakaを使用してより
簡単なアプローチを使用します。let task

<project xmlns:fl="antlib:it.haefelinger.flaka">

...
<!-- overwrite any existing property or userproperty
     (those properties defined on the commandline via -Dfoo=bar ..) --> 
<fl:let> foo ::= 'world'</fl:let>

...
</project>
于 2012-02-09T22:22:08.860 に答える
-1

これは、ant-contrib タグを使用すると機能します。

于 2013-01-18T22:51:32.193 に答える