Gradle insists on v6.6

I recently created a new project in IntelliJ idea. My Gradle cache has 7 different versions from 6.3 to 6.8.3. However for this project Gradle insists on using 6.6, and in fact it regularly re-downloads an entire ZIP file, which it is doing right now as I type this.

I do not see any place in the IDE where v.6.6 is specified, just “wrapper task in Gradle build script” which I am unable to parse.

How can I get this project to tell Gradle to use the latest version I have already on my system, and to stop falling back to 6.6?

If you create a new project in IntelliJ IDEA, the IDE is going to use its own defaults to create the project. Each version of IDEA has a Gradle version that it defaults to using and that version is not configurable in the interface. In your case, this appears to be 6.6.

This means that a new project was setup with gradle/wrapper/ file that references version 6.6. In the IDE, you can specify two different options that interact with this file. The '' file will just use whatever is in that file.

The 'wrapper' task in Gradle build script is similar, but it will run the :wrapper task for you. This will yield the exact same result unless you have a defined a different version in the build.gradle other than what is currently set in

Your third option is to use a Specified location, which uses exactly the version of Gradle that you select.

Gradle will only run with the single version that you run it with or tell it to run with (via the properties file). There is no option in IDEA to tell Gradle to always use the latest version installed. It’s either the version that the project specifies or the exact distribution you can set (which could be a symlink if you wanted to create one for latest).

The use of 6.6 is going to be because that’s what IDEA set in the project’s properties file, which you can either update or use a different specified location.

Thank you, I appreciate the response. I understand Gradle is a totally independent project from IntelliJ and that the Gradle team is not associated with JetBrains. However I would imagine that a huge percentage of Gradle users are doing so within an IntelliJ-based IDE (IDEA or Android Studio). Having a section in the docs that specifically addresses the most popular IDEs would be a huge help, I think this post would make a great start.

Just to be clear, based on your response, there appears to be 4 ways to specify the Gradle version:

executing the command: ./gradlew wrapper --gradle-version 7.0.2

in, set distributionUrl=https\://

in build.gradle, set the gradle version like this:

    gradleVersion = '7.0.2'
    distributionType = Wrapper.DistributionType.BIN

(from How to declare gradle version 5.0 in build.gradle? - Stack Overflow)

in IDEA Settings, in the Gradle page, set Use Gradle from to Specified location, then pick the location of the desired Gradle version

Is this correct?

That’s combining two different concepts. There’s really 2 ways to use a specific Gradle version:

  • Download / install a specific version and run it (gradle).
  • Use the Gradle wrapper, which downloads and run a specific version for the project regardless of what’s installed on the machine (./gradlew).

The wrapper is the preferred approach as it guarantees that the project builds with the version that it was authored for, not whatever someone happened to have installed at the time.

In order to use the wrapper in a project, you need to generate the wrapper files. This includes the gradlew executable, a small JAR file, and the file.

If you just run the wrapper task, it’s going to generate a wrapper with the current version of Gradle that is executing it (if using IDEA to create a project, that’s that default version that they happen to bundle).

Executing ./gradlew wrapper --gradle-version 7.0.2 executes the wrapper task and configures it at command line. The wrapper { } block in build.gradle is exactly the same. It’s just setting your own default for that task so that it doesn’t have to be specified each time. Allowing configuration in the build.gradle or via specific command line options is a pretty normal capability for a task.

The end result of running the wrapper task will generate all the needed wrapper files, including the file. However, if you were in an empty folder, creating a new project yourself manually, you don’t have a working wrapper by just creating The input of the wrapper task is a version. The output includes

Back to the IDEA settings. Use Gradle from:

  • Specified location - use a gradle distribution you’ve already downloaded.
  • '' file - use the wrapper that’s already been generated.
  • 'wrapper' task in Gradle build script - use the wrapper, but run the wrapper task first each time.

Running the wrapper task every time the IDE configures the project is kind of a waste, so I’d always prefer using the wrapper that’s already generated. If you choose the wrapper task option, but don’t configure it in the build.gradle it’s going to get overwritten with IDEA’s bundled version.

Part of the issue ends up being that IDEs change how this is implemented with their different versions. You might be using Gradle 6.6, but a version of IDEA that was released when 5.6.4 or when 7.0.2 was out. It’s also a trailing impact, so when releasing a version of Gradle, it’s not yet known how the IDEs will decide to update in response to that version. Gradle has documentation for the Gradle features, but it really needs to be the IDE that documents what their options (especially when they make up terms for the options) actually do.