Reputation: 493
I am having gradle 4.7 installed on my local and following is my gradle.build which works fine. gradle build is successful on this with gradle plugin version 4.7
buildscript {
ext {
springBootVersion = '1.5.2.RELEASE'
}
repositories {
maven { url "https://artifactory.domain.com/mavenrepo" }
maven { url "https://artifactory.domain.com/maven.atlassian.com-cache" }
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
classpath "gradle.plugin.com.github.sherter.google-java-format:google-java-format-gradle-plugin:0.6"
}
}
apply plugin: "com.github.sherter.google-java-format"
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'idea'
apply plugin: 'org.springframework.boot'
apply plugin: 'findbugs'
apply plugin: 'maven-publish'
group = 'com.domain.xyz.myapp'
version = '1.0.1-SNAPSHOT'
repositories {
maven { url "https://artifactory.domain.com/mavenrepo" }
}
project.tasks.findAll { it.name.startsWith("publish") } .each { it.dependsOn assemble }
springBoot {
classifier = 'boot'
}
publishing {
publications {
maven(MavenPublication) {
artifact ("$buildDir/libs/$project.name-$version-boot.jar") {
classifier = 'boot'
}
}
}
repositories {
maven {
url "http://artifactory.xyz.com:8080/project-snapshots"
credentials {
username = "publish-username"
password = "publish-password"
}
}
}
}
tasks.withType(FindBugs) {
reports {
xml.enabled false
html.enabled true
}
}
configurations {
all*.exclude group: 'javax.servlet', module: 'servlet-api'
}
dependencies {
compileOnly('org.projectlombok:lombok:1.16.14')
compile('org.springframework.boot:spring-boot-starter-actuator')
compile('org.springframework.boot:spring-boot-starter-cache')
compile('org.springframework.boot:spring-boot-starter-data-jpa')
compile('org.springframework.boot:spring-boot-starter-data-ldap')
compile('org.springframework.boot:spring-boot-starter-web')
compile('org.springframework.boot:spring-boot-starter-batch')
compile('org.springframework.boot:spring-boot-starter-jdbc')
compile('org.springframework:spring-web')
compile('com.google.guava:guava:r05')
runtime('mysql:mysql-connector-java:8.0.16')
runtime('org.hsqldb:hsqldb:2.3.3')
runtime('org.springframework.boot:spring-boot-devtools')
testCompile('org.springframework.boot:spring-boot-starter-test')
testCompile('com.jayway.jsonpath:json-path')
compile('com.jcraft:jsch:0.1.53')
compile('net.sourceforge.jtds:jtds:1.3.1')
compile('jcifs:jcifs:1.3.17')
compile('org.apache.camel:camel-core:2.15.0')
compile('com.github.ulisesbocchio:jasypt-spring-boot-starter:1.9')
compile('io.micrometer:micrometer-registry-prometheus:1.0.3')
compile('io.micrometer:micrometer-spring-legacy:1.0.3')
}
When i run gradle build it works fine.
But now I need to upgrade my SpringBootVersion to 2.4.3(latest) and I replace the third line in file with following:
springBootVersion = '2.4.3'
But I get following error:
Failed to apply plugin [id 'org.springframework.boot'] Spring Boot plugin requires Gradle 5 (5.6.x only) or Gradle 6 (6.3 or later). The current version is Gradle 4.7
If gradle build works fine with 4.7, then the the line apply plugin: 'org.springframework.boot'
in 4.7 is also fine and 4.7 can recognise it, why would it ask me to upgrade to later version when 4.7 can build it?What am I missing?How can I upgrade Spring Boot version properly and resolve it?
Upvotes: 1
Views: 17929
Reputation: 712
You are going to need to update gradle, as newer spring boot versions are incompatible with older versions of gradle.
You can either download the new gradle manually or use gradle wrapper to set the version for your project.
You can do this by using the command
gradle wrapper --gradle-version 6.8.3
or
./gradle wrapper --gradle-version 6.8.3
Sometimes gradle will be too old of a version to make an update jump and you will have to download a new version manually anyway (gradle 2 may be too old to go straight to 6 if I remember right.)
To use your wrapper after it is set up just replace your gradle commands with gradlew. Example:
gradlew bootRun
Upvotes: 2
Reputation: 2492
In the buildScript block you have this line of code:
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
This is the code that tells the gradle to which version of spring boot plugin to use. When you change the springBootVersion = '1.5.2.RELEASE'
to springBootVersion = '2.4.3'
, that also affects spring boot version as well as the spring boot plugin version. Hence the error.
Upvotes: 0