mvn 任务失败时如何使 Ant 构建失败?

How to fail Ant build when mvn task fails?

我有一个 Ant 构建,它使用 "artifact:mvn ..." 调用 mvn 任务,如 http://maven.apache.org/ant-tasks/examples/mvn.html 中所述。

问题是,即使这些内部 mvn 构建之一以失败告终,我的整个 Ant 构建仍然会在最后报告构建成功。

当至少一个 mvn 任务失败时,如何让我的 Ant 构建报告构建失败?

The mvn task is a subclass of the Ant java task and supports all of its options

任务可能会立即失败并显示 failonerror="true",或者您可以稍后验证 resultproperty

By default the return code of a <java> is ignored. Alternatively, you can set resultproperty to the name of a property and have it assigned to the result code (barring immutability, of course). When you set failonerror="true", the only possible value for resultproperty is 0. Any non-zero response is treated as an error and would mean the build exits.