Reputation: 43
I want to package in a different way a Java application in order to build the associated Docker image. Basically the current configuration is to build the Docker image based on a folder containing 2 directories :
prog : JAR files of the Java projects that have dependencies between them
lib : libraries of the project (dependencies)
What I would like to do is to create a JAR file containing the content of those two folders.
The Java projects are not all dependent, but there is one defining objects that are used in other projects. I am currently looking for a way to package all of these projects into one JAR. I found a tool called OneJar that would solve my problem, but I am not sure if this would be the right way..
Do you have some suggestions on the way to proceed ?
Thanks !
Upvotes: 0
Views: 615
Reputation: 85
With maven:
The maven Shade plugin will make a single "uber" jar with all your dependencies. 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
You can also look at the google jib project https://github.com/GoogleContainerTools/jib
Upvotes: 1