Configure Eclipse to use the latest version of Gradle

mike rodent picture mike rodent · Jan 2, 2018 · Viewed 12k times · Source

I'm reacquainting myself with Gradle. One of the problems I remember finding when I last looked, using 2.x I think, was multiple versions not only of project implementation jars but also multiple versions of Gradle's own jars.

In an attempt to keep things as clean as possible this time I'd like to get Eclipse to use the latest, greatest Gradle, which at the time of writing is 4.4.1.

I think I understand where this is configured, if one is using the Gradle wrapper:

<project name>/gradle/wrapper/gradle-wrapper.properties

Here I see the crucial last line:

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

I presume what I should do is just change that manually to ... gradle-4.4.1-bin.zip ... But the question is: where is the Buildship plugin actually getting that line from?

When I look under Help --> About Eclipse --> Installation Details --> Buildship there's no sign of anything about Gradle versions.

When I go Window --> Prefs --> Gradle I find you either set the distribution to "Gradle wrapper" (yes, Gradle Goodness) or to a "Specific Gradle version", the highest one currently showing being 4.4.1.

It seems odd that Eclipse should be "aware" that the latest one is 4.4.1 but by default use 3.5!

Answer

howlger picture howlger · Jan 5, 2018

The default Gradle wrapper version is the version of the org.gradle.toolingapi plug-in:

  • Buildship 2.1 (Eclipse Oxygen.1a and Oxygen.2) is shipped with Gradle 3.5 and
  • Buildship 2.2 (update site: http://download.eclipse.org/buildship/updates/e47/releases/2‌.x) with Gradle 4.3.

The names of the preferences are somewhat misleading. Even if Gradle wrapper is not choosen, the New Gradle Project wizard creates a wrapper. Choose Specific Gradle version instead of Gradle wrapper either

  • in Window > Preferences: Gradle or
  • in the Option page of the New Gradle Project dialog after checking the check box Override workspace specific settings:

enter image description here

Note, the Gradle wrapper is to lower the burden to run a Gradle script if the required Gradle version is not yet installed. With Eclipse and Buildship a wrapper is not really needed.