必须有一个我想念的简单设置,请原谅我,但我有两次注意到我的糟糕蚂蚁任务不会导致构建失败.例如:
源文件不存在时的Ant复制... BUILD SUCCESSFUL
Ant解压缩,当任务报告"无法写入文件"或类似消息时......构建成功
Ant exec错误,语法无效......构建成功
如何保证所有ant任务错误都会导致构建失败?
<EXEC>
默认情况下,任务不会失败.你需要启用它failonerror="true"
Ant <COPY>
任务失败取决于使用的资源集合类型.如果您使用fileset
或patternset
,则会以静默方式忽略所有丢失的文件.您只能通过使用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)你试过以下:
<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)