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

Popular posts from this blog

java - UnknownEntityTypeException: Unable to locate persister (Hibernate 5.0) -

python - ValueError: empty vocabulary; perhaps the documents only contain stop words -

ubuntu - collect2: fatal error: ld terminated with signal 9 [Killed] -