Taco Steemers

A personal blog.
☼ / ☾

Solving a Gradle wrapper failure on a fresh Debian install

When I tried to load my gradle project in to IntelliJ IDEA on a fresh Debian install, it failed. I had to upgrade my project's gradle install using the gradle wrapper. It took a few steps. The latest version is 7.1.1, but it didn't work right away.

When I tried to load my gradle project in to IntelliJ IDEA on a fresh Debian install, it failed. I had to upgrade my project's gradle install using the gradle wrapper. It took a few steps. The latest version is 7.1.1, but it didn't work right away.

$ ./gradlew wrapper --gradle-version=7.1.1 --distribution-type=bin

FAILURE: Build failed with an exception.

* What went wrong:
Could not determine java version from '11.0.11'.

It looks like I need a version 11.0.11 JVM to be able to do one of the intermediate gradle upgrades.

The answers here put me on the right track .

In IntelliJ's Gradle settings screen I configured the Java 11.011 SDK, next to the Java 16 SDK I already had. Then I changed

distributionUrl=https\://services.gradle.org/distributions/gradle-4.4.1-bin.zip

to

distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-bin.zip

I also added sourceCompatibility = 11 to the gradle-wrapper.properties file.

The intermediate gradle-wrapper.properties file looked like this:

distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-bin.zip
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStorePath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
sourceCompatibility = 11

I ran the command

./gradlew wrapper --gradle-version=7.1.1 --distribution-type=bin

twice. The first time to update from 4.4.1 to 5.1.1. The second time to upgrade to 7.1.1.

The final gradle-wrapper.properties looked like this:

distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.1.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

Finally, I configured IntelliJ's Gradle settings to use the Java 16 SDK, the SDK I initially wanted to use. Now I can use the latest version of Gradle with my project.