Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/algorithm/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
即使Ant任务失败,Ant也会成功_Ant - Fatal编程技术网

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

即使Ant任务失败,Ant也会成功,ant,Ant,我一定缺少一个简单的设置,所以请原谅我,但我已经注意到有两次我糟糕的ant任务不会导致构建失败。例如: 源文件不存在时的Ant复制。。。建设成功 Ant解压,当任务报告“无法写入文件”或类似消息时。。。建设成功 Ant exec错误,无效语法。。。建设成功 如何保证所有ant任务错误都会导致生成失败?您是否尝试过以下操作: <copy todir="your/path/details" failonerror="true"> </copy> <zip destfi

我一定缺少一个简单的设置,所以请原谅我,但我已经注意到有两次我糟糕的ant任务不会导致构建失败。例如:

  • 源文件不存在时的Ant复制。。。建设成功

  • Ant解压,当任务报告“无法写入文件”或类似消息时。。。建设成功

  • Ant exec错误,无效语法。。。建设成功


  • 如何保证所有ant任务错误都会导致生成失败?

    您是否尝试过以下操作:

    <copy todir="your/path/details" failonerror="true">
    </copy>
    
    <zip destfile="your/path/details" whenempty="fail">
    </zip>
    
    <exec executable="your/path/details" failonerror="true">
    </exec>
    
    
    
    • 默认情况下,任务不会失败。您需要使用
      failonerror=“true”

    • Ant
      任务的失败取决于所使用的资源收集类型。如果使用
      文件集
      模式集
      ,则所有缺少的文件都会被自动忽略。只能通过使用
      文件列表
      类型或使用参数化的“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>
      
      
      

    许多任务都有打开/关闭“FailOneError”的参数,因为有时您不希望任务使构建失败。检查文档并仔细查看参数表。@coolcfan,除非另有指示,否则它应该总是失败,EXEC默认为false是一个错误。我认为我遇到的复制和解压缩问题与试图直接运行ant-launcher.jar有关:(我添加了failonerror=“true”,Ant仍在继续构建。该程序中的“fail-early fail frequency”在哪里?复制默认值为failonerror=“true”,即使手动设置也不会产生失败。复制任务不起作用,因为failureOnError默认设置为true。