Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save artem-zinnatullin/4c250e04636e25797165 to your computer and use it in GitHub Desktop.
Save artem-zinnatullin/4c250e04636e25797165 to your computer and use it in GitHub Desktop.
Prevent Gradle Workers from taking focus! #DevelopersLikeComfort
// 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'
}
}
@edarchis
Copy link

Thanks for the tip, exactly what I needed.

@artem-zinnatullin
Copy link
Author

@edarchis you are welcome!

@emartynov
Copy link

Amazing! Added this flag also to android studio tests run configuration.

Thank you!

@mttkay
Copy link

mttkay commented Jul 27, 2015

❤️

This was annoying the heck out of me. Thanks!

@artem-zinnatullin
Copy link
Author

@mttkay @emartynov #DevelopersWantComfort #DevelopersGetComfort

@hamen
Copy link

hamen commented Aug 6, 2015

👍 thank you so much! Finally, I can use ./gradlew test -t without losing my sanity!

@hamen
Copy link

hamen commented Mar 2, 2016

Only way to make it work with tests, right now, is adding it to the Run configuration:
screen shot 2016-03-02 at 7 47 08 pm

This helped to avoid the window to popup when running ./gradlew:
http://stackoverflow.com/a/13849939/108742

@artem-zinnatullin
Copy link
Author

Another Mac OS specific flag -Dapple.awt.UIElement=true

@edenman
Copy link

edenman commented Jun 28, 2016

for whatever reason, the jvmArgs thing stopped working for me recently. I had to add this to my .bashrc: export JAVA_TOOL_OPTIONS='-Djava.awt.headless=true'

@artem-zinnatullin
Copy link
Author

Uh, same for me, thanks for receipt @edenman

@twixthehero
Copy link

if you use Gradle Kotlin DSL: gradle/kotlin-dsl-samples#439 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment