Did you update to Gradle 8 yet?

Gradle 8.0

A week ago Gradle 8.0 was released. I was totally unprepared.

The previous version was 7.6, so this was a new major version. Yeah, I should have known that things would break.

When possible, I recommend using the latest Gradle version.

In this article, I highlight issues I overcame and the related Gradle features. This might help your update process be less painful.

Java toolchain changes

The Java toolchain forces Gradle to build your application with a specific Java version, irrespective of the version you use to run Gradle itself.

No more “which version of Java were you using” type scenarios.

The Java toolchain is super-easy to implement in your build script:

java {
    toolchain {
        languageVersion = JavaLanguageVersion.of(17)

So what changed in Gradle 8.0?

Well, a super-helpful feature of the Java toolchain is that Gradle looks for the relevant Java version on your system, otherwise tries to download it.

In previous versions of Gradle, the download happened automagically.

In Gradle 8.0, if you haven’t configured the relevant repositories, you get this error:

No locally installed toolchains match … and toolchain download repositories have not been configured …

To fix this, add this plugin to your settings.gradle file, which configures the relevant repositories.

plugins {
    id 'org.gradle.toolchains.foojay-resolver-convention' version '0.4.0'

I’m not exactly sure why Gradle made this change, but auto-download is likely a feature you’ll want to enable.

Task dependency changes

Gradle 8.0 introduced an obscure change which broke my repository, relating to task dependencies.

What are they?

Well, your build consists of multiple tasks which may or may not be executed when you run the Gradle command.

For example, I can add tasks tweedleDee and tweedleDum in build.gradle. Assuming the tasks are unrelated, when I run the following command:

./gradlew tweedleDee

Only the tweedleDee task is executed.

But, I can FORCE tweedleDum to execute whenever tweedleDee is executed by adding a task dependency.

dependsOn tweedleDum

That’s super-helpful when one task depends on the output of another.

So what changed in Gradle 8.0?

If you have a task which depends on the output of another task, and there’s no task dependency, your build will fail. 😔

Reason: Task ‘:taskA’ uses this output of task ‘:taskB’ without declaring an explicit or implicit dependency.

I think it’s a good thing that Gradle now fails in this situation. It’s an easy fix. Just add an explicit dependency using the dependsOn syntax above.

What else?

So far I haven’t covered anything that could be described as a killer feature.

Sorry, but Gradle 8.0 isn’t that kind of release.

There are a couple of other things that are interesting for Java developers, so let’s run through them quickly.

  • build the buildSrc directory separately with ./gradlew buildSrc:build
  • Kotlin build script performance and feature improvements
  • PMD plugin now uses Java version from toolchain

To learn more, head over to the full release notes.

Did you update to Gradle 8 yet?

Leave a Reply

Your email address will not be published. Required fields are marked *

Scroll to top


Getting started with Gradle just got A LOT easier!

Get Going with Gradle is the fastest way to a working knowledge of Gradle.

✅ Work effectively in basic Gradle projects
✅ Know how to setup Java projects in Gradle
✅ Understand the Gradle fundamentals

And it's yours today for FREE!

Where shall I send your access details?

Please wait...

Thank you, check your e-mail inbox for all the details!