From the documentation:
exec:exec
execute programs and Java programs in a separate process.exec:java
execute Java programs in the same VM.
I want to fork a java program. I've already got it working in exec:java
but that doesn't fork. So the obvious move is to change the goal to exec
. Problem is, the syntax for exec
is pretty different from the syntax of java
. It doesn't have tags like includeProjectDependencies
, includePluginDependencies
, etc. Is there a plugin I can use that is like #1 in the sense that it forks, but has a convenient syntax like #2? IMO, #2 should just have a <fork>true</fork>
configuration.
It's also possible to spawn a Java process from Maven with the maven-antrun-plugin. This plugin exports several classpaths covering the compile/runtime/test scopes, as well as the plugin dependencies.
Executing a class in a separate process with the compile and plugin dependencies would thus look like this:
This is executed with
mvn antrun:run
instead ofexec:exec
.I think you can stick to exec:exec, using that kind of configuration if you want to give the project classpath to the Java process you use:
See also the plugin Usage page