Gradle build gets stuck if one of the shoutdown hooks of tests is stuck. This happens because
GradleWorkerMain
calls
System.exit(0)
. Typically it is good but in some cases when test is stuck whole build is never terminated.
The suggestion is to add parameter timeout. Then run System.exit(0) in thread and join it. If thread is not terminated during specified period use
Runtime.getRuntime().halt(1)
. This will make test to fail and build to finish.