// You can place it in the root build.gradle allprojects { tasks.withType(JavaForkOptions) { // Forked processes like GradleWorkerMain for tests won't steal focus! jvmArgs '-Djava.awt.headless=true' } }