我有一個共享的螞蟻腳本b.ant
,它在內部使用antcall
。它計算客戶端腳本使用的屬性。我使用include
而不是import
客戶端腳本來避免無意中覆蓋目標,但這給我帶來了一個antcall問題。在包含的ant文件中使用「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