按照Apache Ant FAQ:
<target name="cond" depends="cond-if"/>
<target name="cond-if" if="prop1">
<antcall target="cond-if-2"/>
</target>
<target name="cond-if-2" if="prop2">
<antcall target="cond-if-3"/>
</target>
<target name="cond-if-3" unless="prop3">
<echo message="yes"/>
</target>
Note: <antcall> tasks do not pass property changes back up to the environment they were called from, so you wouldn't be able to, for example, set a result property in the cond-if-3 target, then do <echo message="result is ${result}"/> in the cond target.
在這方面,它是不可能做你想要使用antcall什麼。
========== 編輯 ===========
嘗試antcallback
:AntCallBack是相同的標準 'antcall' 任務,只是它允許在調用目標中設置的屬性在調用目標中可用。從上面的頁面粘貼
http://antelope.tigris.org/nonav/docs/manual/bk03ch20.html
示例代碼:
<target name="testCallback" description="Test CallBack">
<taskdef name="antcallback" classname="ise.antelope.tasks.AntCallBack" classpath="${antelope.home}/build" />
<antcallback target="-testcb" return="a, b"/>
<echo>a = ${a}</echo>
<echo>b = ${b}</echo>
</target>
<target name="-testcb">
<property name="a" value="A"/>
<property name="b" value="B"/>
</target>
你介意檢查你的問題嗎?你可能不打算讓B打電話B. – rajah9 2011-03-11 17:14:12
@ rajah9:我想在目標A中定義屬性,並在目標B中回顯它。從目標B調用目標A.主要問題是我想要創建一個目標並將其分爲子目標。 – alem0lars 2011-03-11 17:21:29