Search code examples
gradlegradlew

gradlew wrapper update to new version error that you have old version


Why gradle build failed:

 ./gradlew wrapper --gradle-version 6.2

FAILURE: Build failed with an exception.

* Where:
Build file '/home/yburtsev/IdeaProjects/spring-io-testcontainers-workshop/build.gradle' line: 3

* What went wrong:
An exception occurred applying plugin request [id: 'org.springframework.boot', version: '2.2.4.RELEASE']
> Failed to apply plugin [id 'org.springframework.boot']
   > Spring Boot plugin requires Gradle 4.10 or later. The current version is Gradle 4.4.1

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 0s

I manually edit distributionUrl in gradle-wrapper.properties to 6.2 version and than run gradlew wrapper command successfully.

link to project: https://github.com/bsideup/spring-io-testcontainers-workshop


Solution

  • The wrapper task will be run with the previous version of Gradle first. In your case, that is apparently 4.4.1. I don't know why it evaluates the whole project build for the wrapper task, but it does. And since you are using a plugin that is not compatible with that version, it fails.

    As you already did, it can be circumvented by editing the file gradle/wrapper/gradle-wrapper.properties manually and set it to the new version. But remember to run the wrapper task again after you did that. This will make it download the new version and use that to update the other wrapper files if needed.

    There is a corresponding Github issue for this problem. If you like, you can go put a "thumbs up" on it to give it more attention: https://github.com/gradle/gradle/issues/884.