Skip to content

Upgrade to Kotlin 2.2.0 #46238

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

Closed
wants to merge 1 commit into from
Closed

Conversation

sdeleuze
Copy link
Contributor

@sdeleuze sdeleuze commented Jul 1, 2025

This commit leverages Kotlin 2.2 which is expected to be the new baseline for Spring Boot 4.0, so API and language versions are upgraded to KOTLIN_2_2 as well.

It also enables the -Xannotation-default-target=param-property compiler flag, mainly for test purpose, in order to avoid the related warnings and to use what will likely be the default in an upcoming Kotlin version short term. For more details see https://youtrack.jetbrains.com/issue/KT-73255.

KotlinPlatformJvmPlugin was a class from an old KMP plugin, deprecated for a long time and now removed. So its usage in PluginClasspathGradleBuild has been removed as well. @wilkinsona I think I don't see side effects after removing the offending line but please double check as I am not able to run some tests locally.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Jul 1, 2025
@philwebb philwebb added type: enhancement A general enhancement and removed status: waiting-for-triage An issue we've not yet triaged labels Jul 1, 2025
@philwebb philwebb added this to the 4.0.x milestone Jul 1, 2025
@philwebb philwebb added type: dependency-upgrade A dependency upgrade and removed type: enhancement A general enhancement labels Jul 1, 2025
@wilkinsona
Copy link
Member

Thanks, @sdeleuze. Would you mind taking a look at

[[features.kotlin.requirements]]
== Requirements
Spring Boot requires at least Kotlin 2.1.x and manages a suitable Kotlin version through dependency management.
To use Kotlin, `org.jetbrains.kotlin:kotlin-stdlib` and `org.jetbrains.kotlin:kotlin-reflect` must be present on the classpath.
The `kotlin-stdlib` variants `kotlin-stdlib-jdk7` and `kotlin-stdlib-jdk8` can also be used.
Since https://discuss.kotlinlang.org/t/classes-final-by-default/166[Kotlin classes are final by default], you are likely to want to configure {url-kotlin-docs}/compiler-plugins.html#spring-support[kotlin-spring] plugin in order to automatically open Spring-annotated classes so that they can be proxied.
https://github.com/FasterXML/jackson-module-kotlin[Jackson's Kotlin module] is required for serializing / deserializing JSON data in Kotlin.
It is automatically registered when found on the classpath.
A warning message is logged if Jackson and Kotlin are present but the Jackson Kotlin module is not.
TIP: These dependencies and plugins are provided by default if one bootstraps a Kotlin project on https://start.spring.io/#!language=kotlin[start.spring.io].
in the context of Kotlin 2.2 please? We can update the 2.1.x to 2.2.x for the minimum requirements, but I'm also wondering if there any other changes to be made there.

@sdeleuze
Copy link
Contributor Author

sdeleuze commented Jul 1, 2025

Sure I will have a look and refine the documentation accordingly.

This commit leverages Kotlin 2.2 which is expected to be the
new baseline for Spring Boot 4.0, so API and language
versions are upgraded to KOTLIN_2_2 as well.

It also enables the -Xannotation-default-target=param-property
compiler flag, mainly for test purpose, in order to avoid the
related warnings and to use what will likely be the default in
an upcoming Kotlin version short term. For more details see
https://youtrack.jetbrains.com/issue/KT-73255.

KotlinPlatformJvmPlugin was a class from an old KMP plugin,
deprecated for a long time and now removed. So its usage in
PluginClasspathGradleBuild has been removed as well.

Signed-off-by: Sébastien Deleuze <[email protected]>
@sdeleuze
Copy link
Contributor Author

sdeleuze commented Jul 2, 2025

Documentation update pushed.

@wilkinsona wilkinsona modified the milestones: 4.0.x, 4.0.0-M1 Jul 2, 2025
wilkinsona pushed a commit that referenced this pull request Jul 2, 2025
This commit leverages Kotlin 2.2 which is expected to be the
new baseline for Spring Boot 4.0, so API and language
versions are upgraded to KOTLIN_2_2 as well.

It also enables the -Xannotation-default-target=param-property
compiler flag, mainly for test purpose, in order to avoid the
related warnings and to use what will likely be the default in
an upcoming Kotlin version short term. For more details see
https://youtrack.jetbrains.com/issue/KT-73255.

KotlinPlatformJvmPlugin was a class from an old KMP plugin,
deprecated for a long time and now removed. So its usage in
PluginClasspathGradleBuild has been removed as well.

Signed-off-by: Sébastien Deleuze <[email protected]>

See gh-46238
@wilkinsona wilkinsona closed this in 2b9a60f Jul 2, 2025
@wilkinsona
Copy link
Member

Thanks very much, @sdeleuze.

wilkinsona added a commit that referenced this pull request Jul 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: dependency-upgrade A dependency upgrade
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants