当存在重复的类时,Maven 阴影插件会导致构建失败吗?

发布于 2024-10-07 19:07:32 字数 341 浏览 0 评论 0原文

Maven Shade 插件 将项目的 Java 类及其依赖项合并为一个über JAR 文件。如果存在任何重叠(例如,两个依赖项包含具有相同限定名称的类),它会发出警告并(如果我理解正确)使用它遇到的该类的最后一个版本。

对我来说,这似乎有点太宽松了;这种重叠很容易导致运行时的链接或其他问题,例如当重叠的类包含不同的字节码时。

是否可以将阴影插件配置为在存在重叠时使构建失败,而不是仅仅发出警告?这在 CI 服务器上特别有用,因为没有人监视日志文件以查看是否有任何警告。

The Maven shade plugin coalesces your project's Java classes along with its dependencies into a single über JAR file. If there is any overlap (e.g. two dependencies contain a class with the same qualified name), it issues a warning and (if I understand correctly) uses the last version of that class that it comes across.

To me this seems a bit too lax; such an overlap could easily cause linkage or other problems at runtime, e.g. when the overlapping classes contain different bytecode.

Is it possible to configure the shade plugin to fail the build when there are overlaps, instead of just issuing a warning? This would be especially useful on a CI server where nobody is watching the log files to see if there are any warnings.

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

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

发布评论

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

评论(1

堇色安年 2024-10-14 19:07:32

插件里好像没有这样的选项。我已经记录了一个问题请求此操作(更新:也提交了补丁,任何人都可以根据需要自行应用)。

There doesn't seem to be any such option in the plugin. I've logged an issue requesting this (update: and submitted a patch too, which anyone can apply themselves as necessary).

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