Skip to content

Make Boot Gradle plugin setting kotlin.version based on kotlinPluginVersion #11711

@sdeleuze

Description

@sdeleuze

I 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.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions