build.gradle - how to run shell script from Gradle and wait for it to finish -
i'm running shell script gradle, issue shell script running prerequisites need run before gradle continues.
i tried following seems gradle opening child process shell script
sleep.sh echo 'hi1' sleep 1 echo 'hi2' sleep 10 echo 'bye' gradle: task hello3(type: exec) { println 'start gradle....' commandline 'sh','sleep.sh' println 'end gradle....' } result: start gradle.... end gradle.... :hello3 hi1 hi2 bye
your problem println statements executed when gradle parses build.gradle file, not when executes task.
you should move println statements dofirst , dolast follows make things clear:
task hello3(type: exec) { dofirst { println 'start gradle....' } commandline 'sh','sleep.sh' dolast { println 'end gradle....' } }
i believe, gradle waits script finish before doing else, not need special make wait.
gradle start shell script in child process.
Comments
Post a Comment