fileset不支持"erroronmissingdir"属性

Tec*_*ind 5 ant

我正在使用ant 1.7,收到以下错误:

build.xml:55:fileset不支持"erroronmissingdir"属性

1.7中的erroronmissingdir(它在1.8中)的替代属性是什么

sud*_*ode 9

自Ant 1.7.1起,文件集 erroronmissingdir属性可用.您必须使用1.7的早期版本.

该属性用于告诉构建在执行时静默忽略基础目录不存在的文件集:

<copy todir="tmp">
  <fileset dir="foo" erroronmissingdir="false">
    <include name="**/*"/>
  </fileset>
</copy>
Run Code Online (Sandbox Code Playgroud)

如果您未指定erroronmissingdir="false"(或不能,因为您的Ant版本不支持它),那么如果dir foo不存在,则默认结果是构建失败.

如果你需要你的构建成功,无论dir是否存在,并且你不能使用erroronmissingdir属性,你有一些选择.

例如,您可以将文件集的基本目录指定为目标目录的已知存在父级,如下所示:

  <copy todir="tmp">
    <fileset dir=".">
      <include name="foo/**/*"/>
    </fileset>
  </copy>
Run Code Online (Sandbox Code Playgroud)

(注意,在这种情况下,副本会在创建目录FOO todircopy.你可以带,其使用水珠映射器).

另一种选择是在目标中执行有条件可用的文件集操作,例如,由条件保护

<available property="foo.available" file="foo"/>

<target name="test" if="foo.available">
  <copy todir="tmp">
    <fileset dir="foo">
      <include name="**/*"/>
    </fileset>
  </copy>
</target>
Run Code Online (Sandbox Code Playgroud)

输出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
Run Code Online (Sandbox Code Playgroud)