1

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

PrakashFrancis
  • 171
  • 2
  • 12

2 Answers2

2

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.

haba713
  • 2,465
  • 1
  • 24
  • 45
  • is there a way to do it in batch file, I tried it but it is very complicated and couldn't find any solutions. It's not working like shell script. – PrakashFrancis Dec 24 '19 at 11:06
0

I would recommend relying on the support for parallelism inside Gradle itself. It would make your experience much easier.

Unless runSuite1 and runSuite2 are in the same project, recent Gradle version will execute them in parallel. It becomes trivial to register a task that depends on both of these tasks and performs the operation you need.

If runSuite1 and runSuite2 are in parallel and their execution time really would benefit from running them in parallel, see if you can move one of the tasks to a different project.

Louis Jacomet
  • 13,661
  • 2
  • 34
  • 43
  • The intention is mainly to run the programs in parallel where all tasks are under single project. Thanks for your suggestion @Louis Jacomet – PrakashFrancis Dec 11 '19 at 11:20