I have a multimodule maven project, and one of the modules is for distribution.
Project
| moduleA
| moduleB
| ...
| dist-module
The distribution contains an executable jar that I'd like to easily execute. However, to execute it I have to type something like:
java -jar dist-module/target/dist-module-1.0-SNAPSHOT-full-dist/myJar.jar
It would be quite preferable to simply type:
mvn exec:java OR
mvn exec:exec
Unfortunately, I can't find a way to get the java goal to execute a .jar. The exec goal will actually do it, but there's a catch: the jar contains an embedded jetty server, and due to the way exec works (doesn't use the same JVM as maven) the server doesn't terminate unless I kill the process manually, which is similarly bothersome.
Any recommendations on how to do this using maven?
Edit:
For clarification, this command will primarily be used for simple manual smoke-testing; to read the log output and ensure the program started up properly in its distribution environment. As such, it should probably be a blocking call with ctrl-c terminating both the server and maven.
The embedded server is specialized to run a few specific applications, and does not automatically reload them. So, there's not a big need to keep the server running independently of maven for long periods of time.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…