我有一個混亂的構建。最終,目標執行達15次。大多數目標都被執行了十幾次。這是因爲構建和目標分爲10個獨立的構建文件(build.xml
,build-base.xml
,compile.xml
等)。Ant:在antcall構建文件中設置的屬性會發生什麼?
在許多構建文件中,您在構建文件中的所有目標之外都有<property>
任務。這些通常在任何目標被調用之前執行。
這是我build.xml
文件:
<import file="build-base.xml"/>
[...]
<target name="compile-base">
<antcall target="setup-tmpj"/>
<ant antfile="compile.xml" target="compile-base"/>
[...]
</target>
這裏的compile.xml
文件:
<import file="build-base.xml"/>
<property name="target" value="1.5"/>
<available file="target/gensrc/com" property=gensrc.exists"/>
[...]
<target name="buildAndCompileCodeGen" unless=gensrc.exists">
<blah blah blah/>
</target>
<target name="compile-base" depends="buildAndCompileCodeGen">
<blah blah blah/>
</target>
我執行此:
$ ant -f build.xml compile-base
這就要求目標compile-base
在compile.xml
文件。這取決於compile.xml
文件中的目標buildAndCompileCodeGen
。但是,只有在未設置屬性gensrc.exists
時,纔會執行目標buildAndCompileCodeGen
。
在compile.xml
文件是一個<available>
的任務,將設置gensrc.exists
屬性,但這個任務是位於compile.xml
所有目標之外。 <available>
任務曾經被調用過,因此gensrc.exist
被設置了嗎?