[英]Build multiple projects and dependencies into one jar file
I want to package in a different way a Java application in order to build the associated Docker image. 我想以其他方式打包Java应用程序,以构建关联的Docker映像。 Basically the current configuration is to build the Docker image based on a folder containing 2 directories :
基本上,当前配置是基于包含2个目录的文件夹构建Docker映像:
prog : JAR files of the Java projects that have dependencies between them prog:相互依赖的Java项目的JAR文件
lib : libraries of the project (dependencies) lib:项目的库(依赖项)
What I would like to do is to create a JAR file containing the content of those two folders. 我想做的是创建一个包含这两个文件夹内容的JAR文件。
The Java projects are not all dependent, but there is one defining objects that are used in other projects. Java项目不是全部依赖的,但是有一个定义对象可用于其他项目。 I am currently looking for a way to package all of these projects into one JAR.
我目前正在寻找一种将所有这些项目打包到一个JAR中的方法。 I found a tool called OneJar that would solve my problem, but I am not sure if this would be the right way..
我找到了一个名为OneJar的工具来解决我的问题,但是我不确定这是否是正确的方法。
Do you have some suggestions on the way to proceed ? 您对前进的方式有什么建议吗?
Thanks ! 谢谢 !
With maven: 与行家:
The maven Shade plugin will make a single "uber" jar with all your dependencies. Maven Shade插件将创建一个包含所有依赖项的“超级” jar。 https://maven.apache.org/plugins/maven-shade-plugin/index.html
https://maven.apache.org/plugins/maven-shade-plugin/index.html
The spotify docker-maven-plugin will build and push your image with this uber jar: https://github.com/spotify/docker-maven-plugin spotify docker-maven-plugin将使用此超级jar构建并推送您的映像: https : //github.com/spotify/docker-maven-plugin
You can also look at the google jib project https://github.com/GoogleContainerTools/jib 您还可以查看Google三角帆项目https://github.com/GoogleContainerTools/jib
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.