What is the purpose of dependency-reduced-pom.xml generated by the shade plugin?

此生再无相见时 提交于 2019-11-27 13:23:40

问题


I read over the docs and didn't find anything that talks about what it's used for.


回答1:


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

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.




回答2:


I read the docs about 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.

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.



来源:https://stackoverflow.com/questions/22904573/what-is-the-purpose-of-dependency-reduced-pom-xml-generated-by-the-shade-plugin

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!