当存在重复的类时,Maven 阴影插件会导致构建失败吗?
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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
插件里好像没有这样的选项。我已经记录了一个问题请求此操作(更新:也提交了补丁,任何人都可以根据需要自行应用)。
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).