Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
sdeleuze opened this issue Jan 22, 2018 · 8 comments
Closed
Assignees
Labels
type: enhancement A general enhancement
Milestone

Comments

@sdeleuze
Copy link
Contributor

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.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Jan 22, 2018
@wilkinsona wilkinsona added type: enhancement A general enhancement priority: normal and removed status: waiting-for-triage An issue we've not yet triaged labels Jan 22, 2018
@snicoll
Copy link
Member

snicoll commented Jan 22, 2018

start.spring.io sets kotlin.version when Kotlin is selected. So what would be the outcome if we implemented this?

@wilkinsona
Copy link
Member

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.

@wilkinsona wilkinsona self-assigned this Jan 26, 2018
@wilkinsona wilkinsona added this to the 2.0.0.RC1 milestone Jan 26, 2018
@sdeleuze
Copy link
Contributor Author

Thank you so much for that one :-)

@leoedeng
Copy link

Is it possible to move this functionality to the dependency-management plugin? I usually work on multi-module projects, and let the dependency-management plugin manage the dependencies for all the modules. I tried boot 2.0.0.RC1 with kotlin 1.2.21, and it worked perfectly for the modules with boot plugin applied, but in other modules the kotlin-stdlib and kotlin-stdlib-jre7 version were still 1.2.20.

@wilkinsona
Copy link
Member

Unfortunately not, no. The fix relies on knowing that it's the kotlin.version property that controls the version of Kotlin dependencies. That property is specific to Spring Boot's spring-boot-dependencies bom.

@leoedeng
Copy link

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?

@sdeleuze
Copy link
Contributor Author

@leoedeng As of Spring Boot 2.0.0.RC1, both are defined in the dependency management and yes we plan to switch to kotlin-stdlib-jdk8 on start.spring.io, see spring-io/initializr#576 (comment).

@leoedeng
Copy link

leoedeng commented Feb 1, 2018

@sdeleuze Got it. That's really nice.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

5 participants