Make Boot Gradle plugin setting kotlin.version based on kotlinPluginVersion
See original GitHub issueI have got several users mentioning it is not obvious to define Kotlin version in a single place with Gradle plugins { } block (which is the recommended way to use Gradle, especially Gradle Kotlin DSL) and Spring Boot without adding a gradle.properties file (which is not supported yet by Gradle Kotlin DSL). Result can be mixed Kotlin versions in the classpath.
I have been discussing with Gradle team, and they advised to use following syntax in order to be able to sync Spring Boot Kotlin version with Gradle compiler one.
plugins {
val kotlinVersion = "1.2.20"
id("org.jetbrains.kotlin.jvm") version kotlinVersion
id("org.jetbrains.kotlin.plugin.spring") version kotlinVersion
id("org.springframework.boot") version "2.0.0.M7"
id("io.spring.dependency-management") version "1.0.4.RELEASE"
}
extra["kotlin.version"] = plugins.getPlugin(KotlinPluginWrapper::class.java).kotlinPluginVersion
While achieving single definition of Kotlin version without gradle.properties, this is not obvious for users to write this kind of declaration and not very nice to find it in start.spring.io generated projects.
While discussing with @wilkinsona, he mentioned the possibility to update Spring Boot Gradle plugin to react to the Kotlin plugin being applied and set the kotlin.version property to the value of kotlinPluginVersion. This would be a very natural and elegant outcome to this issue.
Issue Analytics
- State:
- Created 6 years ago
- Reactions:7
- Comments:8 (5 by maintainers)

Top Related StackOverflow Question
I suspect there would be no need for
start.spring.ioto do that any more. Instead, It would just configure the Kotlin plugin(s) with the appropriate version and Boot’s Gradle plugin would take care of the rest.Ah, that makes sense. It’s not big deal, I am setting the
kotlin.versionproperty manually like before then. BTW, starting from kotlin 1.2,kotlin-stdlib-jdk8is preferred tokotlin-stdlib-jre8, and alsokotlin-stdlib-jdk7tokotlin-stdlib-jre7. Any plan to replace them in the future?