Maven的 - 如何建立与依赖uberjars [英] maven - How to build uberjars with dependencies
问题描述
我有一个Maven模块生成jar文件。我一直要求开发几个其他uberjar文件
作为构建过程的副产品。我也被告知这两个jar文件的小程序的jar文件
将需要包括来自Maven的模块依赖某些类。
I have a maven module generating a jar file. I have been asked to develop a couple of other uberjar files as a byproduct of build process. I have also been told these 2 jar files are applet jar files that will be need include some classes from the dependencies of the maven module.
我环顾四周,缩小到这3个选项 -
I looked around and narrowed down to these 3 options -
- 的Maven Assembly插件 - 这可以建立从生成的类定制罐由Maven的模块。第三方的依赖不能被包括在内。
- 通过使用Maven的蚂蚁 - 使用 Maven的依赖,插件解压依赖关系,然后通过打包Ant脚本applet的罐子。
- 使用的Maven插件遮阳 - 虽然这个插件是不能直接适用于我的要求,我可以得到它的工作。
- Maven Assembly plugin - This can build custom jars from the classes generated by the maven module. Third party dependencies cant be included.
- Use ant through Maven - Use maven-dependency-plugin to unpack dependencies and then pack the applet jars through ant scripts.
- Use Maven shade plugin - Although this plugin is not directly suited for my requirement, I can get it working.
虽然我可以用的东西(b)和(C)的工作,我无法决定使用哪一个。我注意到一个关键的一点是使用依赖插件是费时。
While I can get things working with (b) and (c), I am unable to decide which one to use. One key thing I have noticed is using the dependency plugin is time consuming.
我想知道是否有其他人的方式达到同样的要求。
I wanted to know if there are other ways people achieve the same requirement.
推荐答案
可以包括使用与 dependencySet
元素Assembly插件的依赖关系,请参见:
You can include dependencies using the assembly plugin with the dependencySet
elements, see:
特别是这里有来自安德鲁·ê布鲁诺的例子节选博客:
<dependencySets>
<dependencySet>
<outputDirectory></outputDirectory>
<outputFileNameMapping></outputFileNameMapping>
<unpack>true</unpack>
<scope>runtime</scope>
<includes>
<include>commons-lang:commons-lang</include>
<include>commons-cli:commons-cli</include>
</includes>
</dependencySet>
</dependencySets>
这篇关于Maven的 - 如何建立与依赖uberjars的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!