question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Make Boot Gradle plugin setting kotlin.version based on kotlinPluginVersion

See original GitHub issue

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.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:7
  • Comments:8 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
wilkinsonacommented, Jan 22, 2018

I suspect there would be no need for start.spring.io to 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.

1reaction
leoedengcommented, Jan 31, 2018

Ah, that makes sense. It’s not big deal, I am setting the kotlin.version property manually like before then. BTW, starting from kotlin 1.2, kotlin-stdlib-jdk8 is preferred to kotlin-stdlib-jre8, and also kotlin-stdlib-jdk7 to kotlin-stdlib-jre7. Any plan to replace them in the future?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Gradle | Kotlin
Gradle is a build system that helps to automate and manage your building process. It downloads required dependencies, packages your code, and prepares...
Read more >
Gradle Kotlin DSL: Define Kotlin version in unique place
It's a common problem to globally define the Kotlin version to be used, both in the dependencies and also in the build plugin...
Read more >
Kotlin version conflict when using Kotlin Gradle plugins in pre ...
In a Gradle 6.5.1 buildSrc/build.gradle.kts I have plugins { `kotlin-dsl` } which of course uses 1.3.72 which is the version embedded in Gradle...
Read more >
Gradle Kotlin DSL Primer
The Kotlin Plugin used by IntelliJ IDEA/Android Studio. Gradle. The level of support varies based on the versions of each. If you run...
Read more >
Sharing Dependencies between Kotlin/SpringBoot Services
Using shared dependencies and gradle plugins with Kotlin and Springboot makes ... plugins { id("org.springframework.boot") version "2.2.1.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found