Spring Boot plugin requires Gradle 4.10 or later. The current version is Gradle 4.1
Asked Answered
B

5

20

I have a Spring Gradle project. I'm trying to make a build using gradle build command. But getting below error :

* Where:
Build file 'F:\MyProjectName\build.gradle' line: 2

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

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

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

BUILD FAILED in 1s

But I'm already using I'm using gradle-5.6.4. and also tried latest gradle-6.0.1-bin but getting same error.

gradle-wrapper.properties

#Wed Dec 04 12:51:57 IST 2019
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStorePath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME

build.gradle

plugins {
    id 'org.springframework.boot' version '2.2.1.RELEASE'
    id 'io.spring.dependency-management' version '1.0.8.RELEASE'
    id 'java'
}

group = 'com.example'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '1.8'

repositories {
    mavenCentral()
}

dependencies {
    implementation 'org.springframework.boot:spring-boot-starter-data-mongodb-reactive'
    implementation 'org.springframework.boot:spring-boot-starter-security'
    implementation 'org.springframework.boot:spring-boot-starter-web'
    implementation 'io.jsonwebtoken:jjwt:0.9.1'
    implementation 'org.springframework.security:spring-security-jwt:1.0.7.RELEASE'
    implementation 'org.springframework.security.oauth:spring-security-oauth2:2.4.0.RELEASE'
    implementation 'de.mkammerer:argon2-jvm:2.6'

    compileOnly 'org.projectlombok:lombok:1.18.10'
    annotationProcessor 'org.projectlombok:lombok:1.18.10'

    testImplementation('org.springframework.boot:spring-boot-starter-test') {
        exclude group: 'org.junit.vintage', module: 'junit-vintage-engine'
    }
    testImplementation 'io.projectreactor:reactor-test'
    testImplementation 'org.springframework.security:spring-security-test'
}

jar {
    enabled true
}

test {
    useJUnitPlatform()
}

How to solve this? Thanks in advance.

Berry answered 25/12, 2019 at 11:13 Comment(2)
What is with this link: distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip ?Orthoepy
This is my default gradle-wrapper.properties file and distributionUrlBerry
B
20

If you're using the command gradle build, then you're not using the wrapper, and thus not using the version of gradle configured in the wrapper properties. You're using the global gradle version installed on your machine.

To use the gradle wrapper, use

./gradlew build

or, on Windows

.\gradlew.bat build

in your project root folder.

Documentation.

Basle answered 25/12, 2019 at 11:22 Comment(3)
That's a completely different issue. Remove your jar { enabled true } section.Basle
Solved my issue using ./gradlew bootJar :)Berry
@Berry you should then accept this answer, which is THE good answer ;)Petta
C
29
  1. Open File gradle-wrapper.properties
  2. You will find distributionUrl with value something like distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.2-bin.zip
  3. Change the gradle version to greater than 4.10 , as I have 5.6.2

Note, this will upgrade the locally scoped gradle version. (As opposed to the system wide gradle install) You will have to use the gradlew(rapper) to invoke.

For example (on linux based)

./gradlew build

I am guessing it would be similar on windows

.\gradlew.bat build

You CANNOT use

gradle build

because that will call the machine-scoped version (which will be the old version probably)

Full locally scoped output below:

./gradlew  build

Welcome to Gradle 5.6.2!

Here are the highlights of this release:
 - Incremental Groovy compilation
 - Groovy compile avoidance
 - Test fixtures for Java projects
 - Manage plugin versions via settings script
Computerize answered 11/6, 2020 at 11:33 Comment(0)
B
20

If you're using the command gradle build, then you're not using the wrapper, and thus not using the version of gradle configured in the wrapper properties. You're using the global gradle version installed on your machine.

To use the gradle wrapper, use

./gradlew build

or, on Windows

.\gradlew.bat build

in your project root folder.

Documentation.

Basle answered 25/12, 2019 at 11:22 Comment(3)
That's a completely different issue. Remove your jar { enabled true } section.Basle
Solved my issue using ./gradlew bootJar :)Berry
@Berry you should then accept this answer, which is THE good answer ;)Petta
M
0

In my case, the cause was an old settings.gradle residing in the project's completely unrelated parent(!) directory.

Minded answered 18/3, 2021 at 15:43 Comment(0)
A
0

In my case some other project in the same workspace ".settings/org.eclipse.buildship.core.prefs" file is having below property

gradle.user.home=C\:/Gradle/gradle-6.7/bin(old version)

replaced with the following:

gradle.user.home=C\:/Gradle/gradle-7.3.2/bin(new version)
Anabelanabella answered 27/12, 2021 at 18:26 Comment(0)
B
0

Gradle 5.6.3 support the spring boot version till 2.4.13

Gradle Spring Boot(max version suported) 5.6.3 2.4.13

Bourgeoisie answered 8/5, 2023 at 9:41 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.