5
我使用Ant 1.7,得到以下錯誤:文件集不支持「erroronmissingdir」屬性
的build.xml:55:文件集不支持「erroronmissingdir」屬性
什麼1.7中的erroronmissingdir的替代屬性(它在1.8中)
我使用Ant 1.7,得到以下錯誤:文件集不支持「erroronmissingdir」屬性
的build.xml:55:文件集不支持「erroronmissingdir」屬性
什麼1.7中的erroronmissingdir的替代屬性(它在1.8中)
fileset erroronmissingdir屬性自Ant 1.7.1起可用。您必須使用早期版本的1.7。
屬性是用來告訴構建悄悄忽略文件集,其基本目錄不會在執行時存在:
<copy todir="tmp">
<fileset dir="foo" erroronmissingdir="false">
<include name="**/*"/>
</fileset>
</copy>
如果不指定erroronmissingdir="false"
(或不能,因爲你的Ant版本不支持它),那麼如果目錄不存在,則默認結果是生成失敗。
如果您需要您的構建成功,而不管目錄是否存在,並且您不能使用erroronmissingdir屬性,那麼您有一些選項。
例如,你可以指定文件集的基礎目錄是你的目標目錄的已知對存在的父母,這樣的事情:
<copy todir="tmp">
<fileset dir=".">
<include name="foo/**/*"/>
</fileset>
</copy>
(注意,在這種情況下,副本將現在建立在copy
的todir
DIR富,你可以帶,其使用水珠mapper)
另一種方法是在目標的條件,例如,以執行有條件可用文件集操作,守衛
<available property="foo.available" file="foo"/>
<target name="test" if="foo.available">
<copy todir="tmp">
<fileset dir="foo">
<include name="**/*"/>
</fileset>
</copy>
</target>
與ant -v
輸出將顯示:
[available] Unable to find foo to set property foo.available
test: Skipped because property 'foo.available' not set.
BUILD SUCCESSFUL Total time: 0 seconds