PrakashFrancis
PrakashFrancis

Reputation: 191

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

Upvotes: 1

Views: 299

Answers (2)

Louis Jacomet
Louis Jacomet

Reputation: 14500

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.

Upvotes: 0

haba713
haba713

Reputation: 2677

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.

Upvotes: 2

Related Questions