【发布时间】:2013-05-31 09:27:24
【问题描述】:
我有一个共享的 ant 脚本 b.ant,它在内部使用 antcall。它计算客户端脚本使用的属性。我使用 include 而不是 import 客户端脚本来避免无意覆盖目标,但这给我的 antcall 带来了问题。
当使用include 时,b 中的所有目标都是前缀,b 中的depends 属性会相应更新。然而,antcall 并非如此。 有没有办法处理这个问题,即让antcall 始终调用“本地”蚂蚁目标?
我可以通过使用import 来解决这个问题,但是我会遇到所有覆盖问题。不能用depends代替antcall。
示例文件
我有两个文件:
a.ant
<project>
<include file="b.ant" as="b" />
<target name="test-depends" depends="b.depend">
<echo>${calculated-property}</echo>
</target>
<target name="test-call" depends="b.call">
<echo>${calculated-property}</echo>
</target>
</project>
b.ant
<project>
<target name="depend" depends="some-target">
<property name="calculated-property" value="Hello World"/>
</target>
<target name="call">
<antcall target="some-target" inheritrefs="true"/>
<property name="calculated-property" value="Hello World"/>
</target>
<target name="some-target"/>
</project>
示例输出
调用 test-depend 按预期工作,但 test-call 失败并出现以下输出:
b.call:
BUILD FAILED
D:\ws\rambo2\ws-dobshl\ant-test\b.ant:6: The following error occurred while executing this line:
Target "some-target" does not exist in the project "null".
Total time: 258 milliseconds
【问题讨论】:
标签: ant