Affects Version/s: 0.9-rc-3
Fix Version/s: None
Currently there is no natural way to execute a java process in the background. Here is a chat I had with merscwog in the IRC channel about this topic:
<edovale> any of you guys know how can I get the javaexec task not to wait for process termination before returning?
<merscwog> Not sure that it can be done right now. Adam would know for sure, but he's not on at the moment. Basically you would need something like the setDaemon() option that the JettyRun tasks have.
<merscwog> Presumably you want to join with the forked process sometime in a later task, or you just want to leave the forked process running until explicitly stopped.
<edovale> I will need to stop the process after the tests are done.
<edovale> Do you think a better approach could be to use the ant exec task?
<merscwog> I've used the built in groovy string execute() methods, or the standard Java ProcessBuilder and calling start() on that and handling the returned Process object later.
<edovale> Thanks, I'll look into that.
<merscwog> You also might consider filing a JIRA about enhancing the Exec task and JavaExec tasks to allow for running something in the background, and setting a Process object as part of the task that can be manipulated by a further task (to allow waitFor() and destroy())
<edovale> Are you then certain that it can not be done now?
<merscwog> No. I am not certain, but it delegates to a org.gradle.process.internal.DefaultJavaExecAction which only has one execute() method, and it has a waitForFinish() call directly before it checks to see if isIgnoreExitValue is set.
<merscwog> Hmm, I guess you could in theory simply override the javaExecHandleBuilder JavaExecAction object and do what you'd want.
<edovale> ok.. that sounds like certainty to me.. I could definetely overwrite the javaExecHandlerBuilder but the IMHO the task should expose this functionality in a more natural way. It doesn't seem to me this is an odd requirement.
<edovale> I'll file the jira issue..