Ant即使Ant任务失败也会成功

cmc*_*nty 11 ant

必须有一个我想念的简单设置,请原谅我,但我有两次注意到我的糟糕蚂蚁任务不会导致构建失败.例如:

  1. 源文件不存在时的Ant复制... BUILD SUCCESSFUL

  2. Ant解压缩,当任务报告"无法写入文件"或类似消息时......构建成功

  3. Ant exec错误,语法无效......构建成功

如何保证所有ant任务错误都会导致构建失败?

cmc*_*nty 8

  • <EXEC>默认情况下,任务不会失败.你需要启用它failonerror="true"

  • Ant <COPY>任务失败取决于使用的资源集合类型.如果您使用filesetpatternset,则会以静默方式忽略所有丢失的文件.您只能通过使用filelist类型或使用参数化的"file"属性来强制执行失败.

    因此,您要使用的是:

    <copy todir="my_dir" file="foo" />
    
    <copy todir="my_dir" flatten="true">
      <filelist dir="" files="foo" />
    </copy>
    
    <copy todir="my_dir" flatten="true">
      <filelist dir="">
         <file name="foo" />
         <file name="bar" />
         <file name="zed" />
      </filelist>
    </copy>
    
    Run Code Online (Sandbox Code Playgroud)


SiB*_*SiB 5

你试过以下:

<copy todir="your/path/details" failonerror="true">
</copy>

<zip destfile="your/path/details" whenempty="fail">
</zip>

<exec executable="your/path/details" failonerror="true">
</exec>
Run Code Online (Sandbox Code Playgroud)