Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/ant/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/csharp-4.0/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ant 修改全局变量蚂蚁_Ant_Ant Contrib - Fatal编程技术网

Ant 修改全局变量蚂蚁

Ant 修改全局变量蚂蚁,ant,ant-contrib,Ant,Ant Contrib,我想在一个目标中更改Ant文件中的“变量”,并在另一个目标中查看该更改 <variable name="foo" value="hello" /> <target name="print-me"> <echo message="${foo}" /> <antcall target="change-me" /> <echo message="${foo}" /> </target> <targe

我想在一个目标中更改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>

当我想打印“你好,世界”时,它会打印“你好,你好”

或者使用:

<target name="change-me">
    <variable name="foo" unset="true"/>
    <variable name="foo" value="world"/>
</target>
任一使用:

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

如果您使用ant contrib标记,这将起作用。

如果您使用ant contrib标记,这将起作用。

在可能的重复项中,您忘记了unset=“true”,在可能的重复项中,变量unset不会影响目标之外的变量。这意味着如果我添加此更改,“print me”目标中的打印仍然打印“hello”。。。我将尝试此附加组件并让您知道。谢谢变量unset不会影响目标之外的变量。这意味着如果我添加此更改,“print me”目标中的打印仍然打印“hello”。。。我将尝试此附加组件并让您知道。谢谢你可能想举个例子来说明你的答案。你可能想举个例子来说明你的答案。