gpt4 book ai didi

ant - subant失败错误的微妙之处

转载 作者:行者123 更新时间:2023-12-03 21:41:05 25 4
gpt4 key购买 nike

我有在所有子目录中启动发布版本的 ant 代码:

<target name="all-release" >
<subant target="sub-release" failonerror="true">
<fileset dir="." includes="*/build.xml" />
</subant>
</target>

如所写,如果任何单个构建失败,则 all-release 将快速失败(以后的构建都不会成功。如果我切换 failonerror="false",则 all-release 将一直成功。事实证明,所有子-builds 是独立的,所以我真正想要的是:

运行所有子发布构建,然后如果一个或多个子发布失败,则所有发布失败(理想情况下,带有关于哪些构建失败的错误消息)。

有任何想法吗?

最佳答案

建议您查看 ant-contrib 中可用的扩展任务。

'for' 任务可能可以根据您的要求进行调整。

您的“全部发布”目标和 ant-contrib taskdef 可能如下所示:

<taskdef resource="net/sf/antcontrib/antlib.xml">
<classpath>
<pathelement location="lib/ant-contrib-1.0b3.jar"/>
</classpath>
</taskdef>

<target name="all-release">
<for keepgoing="true" param="file">
<path>
<fileset dir="." includes="*/build.xml" />
</path>
<sequential>
<ant antfile="@{file}" target="sub-release" />
</sequential>
</for>
</target>

使用其他一些 ant-contrib 功能可能会获得失败列表。

来自上面 build.xml 的示例日志:
$ ant all-release
Buildfile: build.xml

all-release:
[echo] /work/Scratch/dir1/build.xml

sub-release:
[echo] dir1
[echo] /work/Scratch/dir2/build.xml

sub-release:
[echo] dir2
[for] /work/Scratch/dir2/build.xml: The following error occurred while executing this line:
[for] /work/Scratch/build.xml:17: The following error occurred while executing this line:
[for] /work/Scratch/dir2/build.xml:6: dir2 failed
[echo] /work/Scratch/dir3/build.xml

sub-release:
[echo] dir3

BUILD FAILED
/work/Scratch/build.xml:11: Keepgoing execution: 1 of 3 iterations failed.

Total time: 0 seconds

关于ant - subant失败错误的微妙之处,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/497452/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com