I need to run a server(implemented in a Java class) from Maven but if I use the exec:java goal, it will block maven and it will not pass to next phases which connect to the server.
Is there any way to run the exec:java task asynchronously, without interrupting the maven execution?
Thanks!
You could use exec-maven-plugin to run shell script which would start your process and detach from it (letting process to run in background). Something like this:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<executions>
<execution>
<id>start-server</id>
<phase>pre-integration-test</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<executable>src/test/scripts/run.sh</executable>
<arguments>
<argument>{server.home}/bin/server</argument>
</arguments>
</configuration>
</execution>
</executions>
</plugin>
Where run.sh could be like this (for U*nix platform):
#! /bin/sh
$* > /dev/null 2>&1 &
exit 0
That should do the trick.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With