-
Notifications
You must be signed in to change notification settings - Fork 41.1k
Upgrade to Kotlin 2.1.10 #44497
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
Upgrade to Kotlin 2.1.10 #44497
Conversation
Thanks for the PR. Unfortunately, moving the examples to a
It hides the Java sources from Kotlin compilation. |
@wilkinsona thanks for the feedback.
Yes, I wasn't sure about this approach. I changed
and was able to build the docs locally without a problem. Anyway I'll fix the PR according to your suggestion. |
1d9bbc4
to
d757a21
Compare
@@ -304,6 +306,26 @@ task runLoggingFormatExample(type: org.springframework.boot.build.docs.Applicati | |||
normalizeTomcatPort() | |||
} | |||
|
|||
// To avoid a redeclaration error with Kotlin compiler | |||
tasks.withType(KotlinCompile) { | |||
javaSources.from = [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are the Java classes that are used by some of the Kotlin examples. We have 14 such classes.
Another approach is to completely decouple the Java and Kotlin examples and add a Kotlin replacement for each of the below classes. But this must be done carefully since some of these classes are used directly in the include-code
block of the docs, and having a Kotlin version under the same package is unwanted. To prevent Asciidoctor from picking them up, we need to place them in a package with a name that differs from the Java version.
For the record we’ve already done the work of upgrading to Kotlin2. I’d rather us taking this forward and then review whatever needs to be. See 4c6b493 |
@snicoll thanks for the information, didn't know about this. I'll be happy with any decision made by the Spring Boot team. Let me add a couple of comments to the referenced commit.
As I mentioned earlier some of these Java code samples are used directly in the
It’s still possible to compile Kotlin DSL build scripts using Gradle 7.6.4, even when Spring itself is compiled with Kotlin 2.0+. The issue arises due to the presence of multiple Kotlin JARs compiled with Kotlin 2.0+ on the build script classpath, specifically |
- Upgrade kotlinVersion to 2.1.10 - Remove org.jetbrains.kotlin:kotlin-compiler-embeddable from dependencies - Replace deprecated kotlinOptions with compilerOptions - Update KotlinConventions of ConventionsPlugin to set Kotlin apiVersion and languageVersion to 2.1 - Fix redeclaration error with Kotlin compiler on spring-boot-doc - Upgrade PluginClasspathGradleBuild to inject missed Kotlin compiler related jars See spring-projectsgh-38539 Signed-off-by: Dmitry Sulman <[email protected]>
d757a21
to
40cd612
Compare
@dmitrysulman please don't use |
@wilkinsona I see, thanks. |
Closing this PR since it's not relevant. |
Upgrade to Kotlin 2.1.10:
kotlinVersion
to2.1.10
org.jetbrains.kotlin:kotlin-compiler-embeddable
from the classpath, see: https://kotl.in/gradle/internal-compiler-symbolskotlinOptions
withcompilerOptions
, see: https://kotl.in/u1r8lnKotlinConventions
ofConventionsPlugin
to set KotlinapiVersion
andlanguageVersion
to2.1
PluginClasspathGradleBuild
to inject missed Kotlin K2 compiler related jars for running Kotlin Gradle plugin tests on Gradle 8.11+, see Gradle compatibility matrix for Kotlin: https://docs.gradle.org/current/userguide/compatibility.html#kotlinMove all Kotlin examples ofspring-boot-doc
tokotlin
subpackage to preventRedeclaration:
compile errors, see: https://youtrack.jetbrains.com/issue/KTLC-85/Forbid-Java-and-Kotlin-classes-with-the-same-FQ-name-in-sources. This fix introduces most of the changes in the commit.javaSources
from theKotlinCompile
task ofspring-boot-doc
, except for Java classes that are used by some Kotlin example classes, to avoid a redeclaration error with the Kotlin compiler.See gh-38539