I've created a task starting a remote job like
task mytask(type: Exec) {
commandLine 'ssh'
args '-f -l me myserver ./start'.split(' ')
}
and it works, however, it seems to wait for the job to terminate. But it never terminates and it shouldn't.
Doing the same from the command line works: Because of the -f
switch the ssh
command gets executed in the background.
I've tried to add '>&' /dev/null
(csh stdout and stderr redirect) to the command line, but without any success. Also the obvious &
did nothing. I also extracted the command line into a script, and it's always the same: Gradle waits for termination.
I've solved it by using a script and redirecting both stdout and stderr in the script. My problem came from confusing redirections... by passing '>&' /dev/null
I redirected the streams on the remote computer, but what was needed was a redirection on the local one (i.e., without putting the redirection operator in quotes).
Run Gradle testsIn your Gradle project, in the editor, create or select a test to run. From the context menu, select Run <test name>.
Use the command ./gradlew test to run all tests.
The Exec task always waits for termination. To run a background job, use the Ant task 'Exec'
ant.exec(
executable: 'ssh',
spawn: true
) {
arg '-f'
arg '-l'
arg 'me'
arg 'myserver'
arg './start'
}
The Exec
task always waits for termination. To run a background job, you need to write your own task, which could, for example, use the Java ProcessBuilder
API.
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