Gradle toolchains are rarely a good idea

This title could be clearer and more informative.Try out Clickbait Shieldfor free (5 uses left this month).

Jake Wharton argues that Gradle Java toolchains are rarely a good idea for compilation, despite official Gradle and Android documentation recommending them. Using old JDKs via toolchains causes problems: outdated Javadoc (no search before JDK 9), poor container resource awareness, more compiler bugs, slower build performance, and wasted disk space. Since JDK 9 introduced the --release flag, which sets source version, bytecode target, and available APIs in one flag, there is no reason to compile with an old JDK. The recommended approach is to use --release for Java and -Xjdk-release for Kotlin. Toolchains do have legitimate uses: running unit tests on specific JVM versions to test runtime behavior differences, and running tools like Google Java Format or Error-Prone that break on newer JDK internals.

7m read timeFrom jakewharton.com
Post cover image
Table of contents
Bad docsResource ignoranceCompiler bugsWorse performanceNot needed for cross-compilationWasted disk spaceNot the Gradle JVMNot all badWhat do I do?