6

I am running Eclipse Luna SR2 with Buildship 1.0.1.

The Gradle projects I create using the wizard are building with Gradle 2.5-rc-2, but I would like to use 2.6 which is the latest version.

How can I do it?

Setting the task had no effect:

apply plugin: 'java'

repositories {
    jcenter()
}

dependencies {
    testCompile 'junit:junit:4.12'
}

task wrapper(type: Wrapper) {
    gradleVersion = '2.6'
}

Solution: For some reason it is only working if I restart Eclipse after setting the version as Makoto suggested.

Evandro Pomatti
  • 13,341
  • 16
  • 97
  • 165
  • I just want to make certain: you've run the `wrapper` task, right? Have you executed `./gradlew --version` or the Windows equivalent? – Makoto Aug 16 '15 at 21:16
  • Yes, wrapper task and no, not using command line I wish to do it from the IDE. But once I restarted Eclipse it worked. Not sure why =O . I will try at my PC at home to see if the same happens so I can report a bug. – Evandro Pomatti Aug 16 '15 at 21:48
  • 1
    @Makoto Your asnwer is correct, but I had to restart Eclipse for it to work. – Evandro Pomatti Aug 16 '15 at 22:39

3 Answers3

7

If you want to use the wrapper, it's a simple matter of setting the gradleVersion property:

task wrapper(type: Wrapper) {
    gradleVersion = '2.6'
}
Makoto
  • 104,088
  • 27
  • 192
  • 230
  • 3
    if running from the command line you could also do: gradlew wrapper --gradle-version 2.6 – Kyle C Nov 17 '15 at 23:40
  • 1
    This doesn't update the `build.gradle` file in my experience. – Makoto Nov 17 '15 at 23:44
  • 1
    it won't update the build.gradle file, but it will update the gradle version in the gradle wrapper. In buildship I had to restart eclipse to get it to work regardless. – Kyle C Nov 18 '15 at 18:10
0

You can create a new Run Configuration of type Gradle Project running the task wrapper. Running this run configuration should update the wrapper version without the need to restart eclipse.

0

I had the same issue with different versions. The solution is to add the following task to your build file, then run gradle wrapper task in the project root folder:

task wrapper(type: Wrapper) {
  gradleVersion = '2.6'
}

The reason the wrong version of wrapper was used for the build is that there was no wrapper created for the version I wanted to use.