I'm building a java service which has two distribution. Each distribution must be build different (one has a spring-boot embedded jetty server inside, the other not). In both, I created a distribution with dependencies, except one (already achieved). The jar without jetty is build using maven-assembly-plugin
(similarly as here Problems running executable jar with dependencies) the other one uses spring-boot-maven-plugin
(see http://docs.spring.io/spring-boot/docs/current/maven-plugin/usage.html). My issue is the external dependencies.
I want add an additional dependency on runtime, but I DON'T WANT TO US OSGi
In both building process the result is a 'executable' jar, which I can run like this:
java -jar my.jar
But I don't know how to address the additional dependencies. If I run the command above without a the external dependency (lets say external.jar) inside my.jar will fail, even if is in the same folder. I can make it work for the distribution without jetty like this:
java -classpath "./*" my.main.App
But this doesn't work for my-with-jetty.jar. I also try to run:
java -classpath "./*" -jar my-with-jetty.jar
This simply doesn't work.
So my question are:
is it possible to pack a jar with almost all the dependencies for both cases?
is it possible to pack the jar as runnable jar such that it not necessary to provide the main class?
of course if yes, how? I would like to run both distribution in the same manner.
I want similar behavior:
java -cp "./*" java -jar my.jar conf.cfg
and
java -cp "./*" java -jar my-rest.jar conf.cfg
Thank you.