Apache Commons Exec launches the process in a separate thread (slightly related to EXEC-121), so what could happen is that before the JavaFX process is launched Maven exits.
In reality it is probably rather unlikely that this will happen because that executor thread launches the process as first action and on the other hand it takes some time until the JavaFX plugin and Maven finish and the JVM exits. But it is not impossible that this can occur.
It can for example be demonstrated by running with mvnDebug clean javafx:run "-Djavafx.async=true" "-Djavafx.asyncDestroyOnShutdown=false" and setting a breakpoint in org.apache.commons.exec.DefaultExecutor.executeInternal to pause execution there.
Potential solution
One potential solution might be to add a CountDownLatch or similar with initial value of 1. Then supply a custom ExecuteStreamHandler to exec whose start() method calls countDown(), and additionally in onProcessFailed also call countDown() (to avoid a dead lock in case of a failure).
And then have org.openjfx.JavaFXBaseMojo.executeCommandLine call countDownLatch.await() after calling execute. This should then make sure that the process was launched before the JavaFX plugin (and eventually the JVM) exits.
(Have not tested this though)
As side note: Maybe onProcessFailed in org.openjfx.JavaFXBaseMojo.executeCommandLine should also call psh.stop() to be safe?
Version
0.0.8
Description
Apache Commons Exec launches the process in a separate thread (slightly related to EXEC-121), so what could happen is that before the JavaFX process is launched Maven exits.
In reality it is probably rather unlikely that this will happen because that executor thread launches the process as first action and on the other hand it takes some time until the JavaFX plugin and Maven finish and the JVM exits. But it is not impossible that this can occur. It can for example be demonstrated by running with
mvnDebug clean javafx:run "-Djavafx.async=true" "-Djavafx.asyncDestroyOnShutdown=false"
and setting a breakpoint inorg.apache.commons.exec.DefaultExecutor.executeInternal
to pause execution there.Potential solution
One potential solution might be to add a
CountDownLatch
or similar with initial value of 1. Then supply a customExecuteStreamHandler
toexec
whosestart()
method callscountDown()
, and additionally inonProcessFailed
also callcountDown()
(to avoid a dead lock in case of a failure). And then haveorg.openjfx.JavaFXBaseMojo.executeCommandLine
callcountDownLatch.await()
after callingexecute
. This should then make sure that the process was launched before the JavaFX plugin (and eventually the JVM) exits. (Have not tested this though)As side note: Maybe
onProcessFailed
inorg.openjfx.JavaFXBaseMojo.executeCommandLine
should also callpsh.stop()
to be safe?