从 Maven 插件检测 Maven 构建状态(成功/错误)

发布于 2024-09-07 01:33:34 字数 72 浏览 2 评论 0原文

我想知道如何从 Maven 插件获取构建状态 (ERROR/SUCCESS)?

I am wondering how would one get the status of a build (ERROR/SUCCESS) from a Maven plugin ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

小草泠泠 2024-09-14 01:33:34

你不能轻易做到这一点。 Maven 插件失败并抛出 org.apache.maven.plugin.MojoExecutionException
或 org.apache.maven.plugin.MojoFailureException ,并且您没有钩子来监听这些异常。当然不是使用插件,因为你的插件在失败后不会被执行。

可能可以使用

org.apache.maven.lifecycle.DefaultLifecycleExecutor 的自定义版本
或者
您可以通过 plexus 注入org.apache.maven.DefaultMaven

并将插件执行包装在 try / catch 中以随后执行您的逻辑,但这是非常繁重的东西。

请阅读此处了解访问 plexus 容器

You can't easily do that. Maven plugins fail by throwing a org.apache.maven.plugin.MojoExecutionException
or a org.apache.maven.plugin.MojoFailureException, and you don't have a hook to listen to these exceptions. Certainly not with a plugin, because your plugin wouldn't be executed after a failure.

There might be the possibility to use custom versions of

org.apache.maven.lifecycle.DefaultLifecycleExecutor
or
org.apache.maven.DefaultMaven

that you can inject via plexus and wrap plugin execution in try / catch to perfom your logic afterwards, but this is very heavy stuff.

Read here about accessing the plexus container

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文