How to know the gradle process has ended?

I want to get the gradle running process where I can come to know that gradle task has ended. I am executing gradle tasks parallel in my machines like following.

in Windows,

start gradlew runSuite1 -i --rerun-tasks
start gradlew runSuite1 -i --rerun-tasks

in Mac,

 ./gradlew runSuite1 -i --rerun-tasks &
 ./gradlew runSuite2 -i --rerun-tasks &

It will trigger all gradle operations in parallel.

I want to perform one operation once all this gradle tasks are ended.

How to know these gradle running process using java or anything ?

Thanks in advance

1 answer

  • answered 2019-12-09 14:39 haba713

    You can use command wait in Bash:

    ./gradlew runSuite1 -i --rerun-tasks &
    pids[0]=$!
    
    ./gradlew runSuite2 -i --rerun-tasks &
    pids[1]=$!
    
    for pid in ${pids[*]}; do
        wait $pid
    done
    

    See this answer for more information.