4

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!

mike rodent
  • 14,126
  • 11
  • 103
  • 157
  • The Eclipse IDE for Java Developers Oxygen.2 contains an embedded Gradle 3.5 as plug-in `org.gradle.toolingapi` version 3.5.0.v20170801075239 (= Gradle 3.5.0, built/packed on August 1, 2017). – howlger Jan 02 '18 at 18:29
  • Thanks... I wonder what this means for one's ability to tweak in the way I have? I have indeed substituted "gradle-4.4.1-bin.zip" in gradle-wrapper.properties... and I have "closed out" (renamed) the directory GRADLE_USER_HOME\caches\3.5\ ... it has not regenerated itself, and I just ran the "build" task, seemingly using 4.4.1 Ok. (GRADLE_USER_HOME\caches\4.4.1\ is now present) – mike rodent Jan 02 '18 at 19:47
  • A newer Gradle version than the version of the embedded Gradel might break the Gradle support of Eclipse. Therefore using the latest version of Gradle might be a little risky. I recommend upgrading Buildship. The latest version of Buildship is 2.2 which is not contained in Oxygen.2 and which contains Gradle 4.3 (update site: `http://download.eclipse.org/buildship/updates/e47/releases/2.x`). – howlger Jan 03 '18 at 23:42
  • Thanks ... makes sense, specially as 4.3 is so recent. It's funny how (in Eclipse) you can configure the versions of Java, Python, etc. ... but not other things, like JavaScript or Gradle. No doubt there are sound technical reasons why this is difficult to implement... – mike rodent Jan 04 '18 at 11:58
  • You can configure the version of Gradle. [Since Buildship 2.1 even on three levels: workspace (_Window > Preferences: Gradle_), project (_Project > Properties: Gradle_) and run configuration (in the _Project Settings_ tab).](http://projects.eclipse.org/projects/tools.buildship/releases/2.1.0) – howlger Jan 04 '18 at 12:56
  • Sorry, I meant you have to choose between configuring the version and using the wrapper. I'm a very low-level Gradle practitioner but absolutely everyone says "always use the wrapper" (I don't know why, but hope to find out!) ... haven't looked at the run configuration but presume the same either-or choice applies there ... – mike rodent Jan 04 '18 at 13:01
  • [The Gradle wrapper lowers the burden to run a Gradle script if Gradle is not yet installed.](https://docs.gradle.org/current/userguide/gradle_wrapper.html) With Eclipse and Buildship Gradle is embedded and the wrapper is not required. If you're wondering why the Gradle version included in Buildship is lagging behind: every new version of Gradle that is shipped with Buildship must pass the [Eclipse IP process](http://www.eclipse.org/community/eclipse_newsletter/2014/july/article4.php). – howlger Jan 04 '18 at 13:30
  • Thanks for clarifying use of the wrapper... in fact under Window --> Prefs --> Gradle --> Specific Gradle version I have a choice of many versions, latest 4 being 4.3, 4.3.1, 4.4 and 4.4.1. NB This is Eclipse Oxygen 4.7.1a. Buildship is "2.1.2.v20170807 - 1324" – mike rodent Jan 04 '18 at 16:18

1 Answers1

4

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.

howlger
  • 31,050
  • 11
  • 59
  • 99
  • Aha... all suddenly becomes clear. Confirmed: gradle-wrapper.properties created with distributionUrl set to 4.4.1. Thanks very much. – mike rodent Jan 05 '18 at 12:28