Java shade插件生成的dependency-reduced-pom.xml的目的是什么?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/22904573/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
What is the purpose of dependency-reduced-pom.xml generated by the shade plugin?
提问by Transcendence
回答by Tome
The shade:shade Mojo is quite well documented, here especially about the createDependencyReducedPom
parameter, which will create that dependency-reduced-pom.xml
file: maven-shade-plugin/shade-mojo.html#createDependencyReducedPom
shade:shade Mojo 有很好的文档记录,这里特别是关于createDependencyReducedPom
参数,它将创建该dependency-reduced-pom.xml
文件:maven-shade-plugin/shade-mojo.html#createDependencyReducedPom
In short, this is quite useful if you intend to use that shaded JAR (instead of the normal JAR) as a dependency for another module. That dependency-reduced-pom.xml
will not contain the JARs already present in the shaded one, avoiding useless duplication.
简而言之,如果您打算使用着色的 JAR(而不是普通的 JAR)作为另一个模块的依赖项,这将非常有用。这dependency-reduced-pom.xml
将不包含阴影中已经存在的 JAR,从而避免无用的重复。
回答by morpheus
I read the docsabout a hundred times or so and still couldn't understand what this is for, what really is the use case for it.
我阅读了大约一百次左右的文档,但仍然无法理解它的用途,它的真正用例是什么。
Finally this is what I think: lets say you have a project with dependencies A, B, C, D, E. In the pom.xml
you configure the shade plugin in such a way that when it creates the uber-jar (call it foo.jar
), it includes A, B, C in the shaded jar but for some reason you decide not to include D, E in the shaded jar even though your project depends on them - a case in point are dependencies that are needed only for testing (e.g. any dependency that has a scope
of test
and is not included in the shaded jar). The dependency-reduced-pom.xml
will define D, E in it. The idea is that if someone wants to use foo.jar
the dependency-reduced-pom.xml
provides a hint of some sort that beware foo.jar
is missing dependencies D, E in it - use at your own risk. You might then decide to explicitly add D, E in the project that will use foo.jar
.
最后,这就是我的想法:假设您有一个依赖项 A、B、C、D、E 的项目。在pom.xml
您配置 shade 插件时,当它创建 uber-jar(调用它foo.jar
)时,它在阴影 jar 中包含 A、B、C 但由于某种原因您决定不将 D、E 包含在阴影 jar 中,即使您的项目依赖于它们 - 一个例子是仅用于测试的依赖项(例如任何依赖项具有scope
的test
,并且不包括在阴影罩)。在dependency-reduced-pom.xml
将它定义d,E。我们的想法是,如果有人想使用foo.jar
的dependency-reduced-pom.xml
提供了一些那种提防的暗示foo.jar
是缺少依赖d,E在里面-使用您自己的风险。然后,您可能决定在将使用的项目中明确添加 D、Efoo.jar
.
So the dependency-reduced-pom.xml
is more like missing-dependencies.xml
and lists the dependencies which are missing in the uber-jar which is output by the shade plugin.
所以dependency-reduced-pom.xml
更像是missing-dependencies.xml
并列出了由 shade 插件输出的 uber-jar 中缺少的依赖项。