且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Maven - 添加jar-with-dependencies作为依赖项

更新时间:2022-04-30 18:22:18

您可以使用 maven分类器执行此操作。使用类文件,因此maven模块可以从同一来源构建多个人工制品。示例是jdk1.6或1.7版本,甚至是maven可以构建的源代码和javadoc jars。

You can do this with a maven classifier. Classfiers are used so a maven module can build multiple artefacts from the same source. Examples are jdk1.6 or 1.7 version or even the source and javadoc jars maven can build.

所以试试这个:

<dependency>
  <groupId>yourID</groupId>
  <artifactId>seaniscool</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <classifier>jar-with-dependencies</classifier>
</dependency>

如果您想将您的类文件重命名为更好的名称,例如withNative或者完整或其他任何看起来在 maven shade插件中,它还可以构建具有依赖关系的jar,但允许更多控制。

If you want to rename your classfier to a better name like withNative or complete or anything else have a look at the maven shade plugin which can also build jars with dependencies but allows some more control.