Repository navigation
Bump kotlin to 2.4.20; as most implementations are eol... Also, as a side effect; values() will be deprecated for kotlin enums, use entries instead from 1.9 onwards - #25246
Conversation
There was a problem hiding this comment.
All reported issues were addressed across 5 files
Reply with feedback, questions, or to request a fix.
View guided diff | Re-trigger cubic
|
@dijkstrar thanks for the PR. May I know why it's closed? |
Hi @wing328 ! I initially thought the change would be easy to implement. But upon closer inspection, I discovered that it would be a bumpy road. I was thinking of two options.
The first option would be rather cumbersome for me to implement. Option 2 would be most straightforward, and is a call I can not make on my own (and did not want to put in the work, unless it would be sure i could proceed with it ;) ) Do you have any thoughts on this? |
I think this is preferred as the kotlin version currently used is quite old (EOL?): https://endoflife.date/kotlin so make sense to upgrading the kotlin version in templates to 2.4. |
|
aye, sounds like a plan; i will try to do it ;) |
There was a problem hiding this comment.
2 issues found across 143 files (changes from recent commits).
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="samples/openapi3/client/petstore/kotlin-multiplatform/build.gradle">
<violation number="1" location="samples/openapi3/client/petstore/kotlin-multiplatform/build.gradle:21">
P1: The compiler plugin is now 2.4.20 but the serialization runtime stays at 0.12.0 and the Gradle wrapper stays at 7.2. Kotlin 2.x generates code against kotlinx-serialization 1.x APIs and expects a newer Gradle, so this build will likely fail to compile or configure. Bump `serialization_version` to a 1.x runtime and update `gradle-wrapper.properties` together with this change.</violation>
</file>
<file name="samples/openapi3/client/petstore/kotlin-jvm-retrofit2-coroutines/build.gradle">
<violation number="1" location="samples/openapi3/client/petstore/kotlin-jvm-retrofit2-coroutines/build.gradle:10">
P2: The Kotlin bump is not paired with a Gradle bump. `wrapper { gradleVersion = '4.9' }` is still set, and Kotlin 2.x's Gradle plugin will not run on Gradle 4.9. Raise the wrapper to a Gradle version that supports Kotlin 2.4 and switch `compile`/`testCompile` to `implementation`/`testImplementation`. Also update the Kotlin and Gradle versions in the README 'Requires' section.</violation>
</file>
Reply with feedback, questions, or to request a fix.
View guided diff | Re-trigger cubic
| classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.50" // $kotlin_version | ||
| classpath "org.jetbrains.kotlin:kotlin-serialization:1.3.50" // $kotlin_version | ||
| classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:2.4.20" // $kotlin_version | ||
| classpath "org.jetbrains.kotlin:kotlin-serialization:2.4.20" // $kotlin_version |
There was a problem hiding this comment.
P1: The compiler plugin is now 2.4.20 but the serialization runtime stays at 0.12.0 and the Gradle wrapper stays at 7.2. Kotlin 2.x generates code against kotlinx-serialization 1.x APIs and expects a newer Gradle, so this build will likely fail to compile or configure. Bump serialization_version to a 1.x runtime and update gradle-wrapper.properties together with this change.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At samples/openapi3/client/petstore/kotlin-multiplatform/build.gradle, line 21:
<comment>The compiler plugin is now 2.4.20 but the serialization runtime stays at 0.12.0 and the Gradle wrapper stays at 7.2. Kotlin 2.x generates code against kotlinx-serialization 1.x APIs and expects a newer Gradle, so this build will likely fail to compile or configure. Bump `serialization_version` to a 1.x runtime and update `gradle-wrapper.properties` together with this change.</comment>
<file context>
@@ -17,8 +17,8 @@ buildscript {
- classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.50" // $kotlin_version
- classpath "org.jetbrains.kotlin:kotlin-serialization:1.3.50" // $kotlin_version
+ classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:2.4.20" // $kotlin_version
+ classpath "org.jetbrains.kotlin:kotlin-serialization:2.4.20" // $kotlin_version
}
}
</file context>
There was a problem hiding this comment.
All reported issues were addressed across 45 files (changes from recent commits).
Reply with feedback, questions, or to request a fix.
View guided diff | Re-trigger cubic
Co-authored-by: cubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com>
There was a problem hiding this comment.
3 issues found across 47 files (changes from recent commits).
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="samples/openapi3/server/petstore/kotlin-springboot/build.gradle.kts">
<violation number="1" location="samples/openapi3/server/petstore/kotlin-springboot/build.gradle.kts:24">
P2: Bumping Kotlin to 2.4.20 here, while this sample still uses Spring Boot 2.2.0.M3 and dependency-management 1.0.5, may not produce a working build. Spring Boot 2.2's BOM likely pins kotlin-stdlib to an old 1.3.x version, and the `compile` configurations need Gradle 6 or older. Please build the sample to confirm, or regenerate it from the sb2.6.7 template (`buildGradleKts.mustache`) so the Spring Boot and Kotlin versions match.</violation>
</file>
<file name="samples/openapi3/server/petstore/kotlin-springboot-reactive/build.gradle.kts">
<violation number="1" location="samples/openapi3/server/petstore/kotlin-springboot-reactive/build.gradle.kts:24">
P2: Bumping to Kotlin 2.4.20 requires a modern Gradle, but this build still uses the `compile(...)` configuration, which Gradle 7+ removed. The build will fail at configuration time on any Gradle version that supports this Kotlin version. Switch the dependency declarations to `implementation`/`testImplementation`, as the template does, or keep the Kotlin version aligned with the Gradle version in use.</violation>
</file>
<file name="samples/server/petstore/kotlin-springboot-reactive/build.gradle.kts">
<violation number="1" location="samples/server/petstore/kotlin-springboot-reactive/build.gradle.kts:24">
P2: The Kotlin plugins move to 2.4.20, but the Spring dependency-management plugin still pins kotlin-stdlib and kotlin-reflect to the Spring Boot BOM's Kotlin version, which is likely much older. Consider pinning `extra["kotlin.version"] = kotlinVersion` so the stdlib and reflect artifacts match the compiler, as the pom.xml already does.</violation>
</file>
Reply with feedback, questions, or to request a fix.
View guided diff | Re-trigger cubic
|
|
||
| plugins { | ||
| val kotlinVersion = "1.3.30" | ||
| val kotlinVersion = "2.4.20" |
There was a problem hiding this comment.
P2: Bumping Kotlin to 2.4.20 here, while this sample still uses Spring Boot 2.2.0.M3 and dependency-management 1.0.5, may not produce a working build. Spring Boot 2.2's BOM likely pins kotlin-stdlib to an old 1.3.x version, and the compile configurations need Gradle 6 or older. Please build the sample to confirm, or regenerate it from the sb2.6.7 template (buildGradleKts.mustache) so the Spring Boot and Kotlin versions match.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At samples/openapi3/server/petstore/kotlin-springboot/build.gradle.kts, line 24:
<comment>Bumping Kotlin to 2.4.20 here, while this sample still uses Spring Boot 2.2.0.M3 and dependency-management 1.0.5, may not produce a working build. Spring Boot 2.2's BOM likely pins kotlin-stdlib to an old 1.3.x version, and the `compile` configurations need Gradle 6 or older. Please build the sample to confirm, or regenerate it from the sb2.6.7 template (`buildGradleKts.mustache`) so the Spring Boot and Kotlin versions match.</comment>
<file context>
@@ -21,7 +21,7 @@ tasks.withType<KotlinCompile> {
plugins {
- val kotlinVersion = "1.3.30"
+ val kotlinVersion = "2.4.20"
id("org.jetbrains.kotlin.jvm") version kotlinVersion
id("org.jetbrains.kotlin.plugin.jpa") version kotlinVersion
</file context>
|
|
||
| plugins { | ||
| val kotlinVersion = "1.3.30" | ||
| val kotlinVersion = "2.4.20" |
There was a problem hiding this comment.
P2: Bumping to Kotlin 2.4.20 requires a modern Gradle, but this build still uses the compile(...) configuration, which Gradle 7+ removed. The build will fail at configuration time on any Gradle version that supports this Kotlin version. Switch the dependency declarations to implementation/testImplementation, as the template does, or keep the Kotlin version aligned with the Gradle version in use.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At samples/openapi3/server/petstore/kotlin-springboot-reactive/build.gradle.kts, line 24:
<comment>Bumping to Kotlin 2.4.20 requires a modern Gradle, but this build still uses the `compile(...)` configuration, which Gradle 7+ removed. The build will fail at configuration time on any Gradle version that supports this Kotlin version. Switch the dependency declarations to `implementation`/`testImplementation`, as the template does, or keep the Kotlin version aligned with the Gradle version in use.</comment>
<file context>
@@ -21,7 +21,7 @@ tasks.withType<KotlinCompile> {
plugins {
- val kotlinVersion = "1.3.30"
+ val kotlinVersion = "2.4.20"
id("org.jetbrains.kotlin.jvm") version kotlinVersion
id("org.jetbrains.kotlin.plugin.jpa") version kotlinVersion
</file context>
|
|
||
| plugins { | ||
| val kotlinVersion = "1.9.25" | ||
| val kotlinVersion = "2.4.20" |
There was a problem hiding this comment.
P2: The Kotlin plugins move to 2.4.20, but the Spring dependency-management plugin still pins kotlin-stdlib and kotlin-reflect to the Spring Boot BOM's Kotlin version, which is likely much older. Consider pinning extra["kotlin.version"] = kotlinVersion so the stdlib and reflect artifacts match the compiler, as the pom.xml already does.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At samples/server/petstore/kotlin-springboot-reactive/build.gradle.kts, line 24:
<comment>The Kotlin plugins move to 2.4.20, but the Spring dependency-management plugin still pins kotlin-stdlib and kotlin-reflect to the Spring Boot BOM's Kotlin version, which is likely much older. Consider pinning `extra["kotlin.version"] = kotlinVersion` so the stdlib and reflect artifacts match the compiler, as the pom.xml already does.</comment>
<file context>
@@ -21,7 +21,7 @@ tasks.withType<KotlinCompile> {
plugins {
- val kotlinVersion = "1.9.25"
+ val kotlinVersion = "2.4.20"
id("org.jetbrains.kotlin.jvm") version kotlinVersion
id("org.jetbrains.kotlin.plugin.jpa") version kotlinVersion
</file context>
There was a problem hiding this comment.
2 existing issues remain and no new issues found across 32 files (changes from recent commits).
Requires human review: Auto-approval blocked because this review re-detected 3 unresolved issues already reported by Cubic.
View guided diff | Re-trigger cubic
There was a problem hiding this comment.
1 existing issue remains and no new issues found across 34 files (changes from recent commits).
Requires human review: Auto-approval blocked because this review re-detected 7 unresolved issues already reported by Cubic.
View guided diff | Re-trigger cubic
…ipt is at 1.8.22 as max version, kotlin major version is at 2
|
Hi @wing328 , could you please review this? :) I put a lot of work in creating this PR and want the review process to get started; as constantly keeping the branch up-to-date is cumbersome... hope to hear from you soon! please note that one of the samples is failing, due to a 429 from maven repo's end but it should pass ;) |
|
Thank you @dijkstrar cc Kotlin technical committee as well: @karismann (2019/03) @Zomzog (2019/04) @andrewemery (2019/10) @4brunu (2019/11) @yutaka0m (2020/03) @stefankoppier (2022/06) @e5l (2024/10) |
|
also cc recent top contributors to Kotlin generators: @Picazsoo @seonwooj0810 @raunak2007 @WonderCsabo |
Thanks for sticking with this. I know how annoying it is to keep rebasing a PR of this size. Moving off the old Kotlin pins is overdue, and switching to My concern is that 2.4.20 may be more than this change needs. As far as I understand,
Users can work around all of this with their own build file, but the defaults should probably be the most compatible option. A possible alternative:
If the committee prefers to go with the latest version anyway, that's fine with me. Either way, raising the minimum Kotlin for generated code is a breaking change and should be labeled and noted in the release notes. |
Definitely. cc @AndreyVMarkelov who just joined the technical committee |
|
@Picazsoo Kotlin client is already on |
AndreyVMarkelov
left a comment
There was a problem hiding this comment.
This introduces a Kotlin compilation error for a numeric anyOf variant when using jvm-retrofit2, gson, and generateOneOfAnyOfWrappers=true.
The generated require block contains an extra comma after the error message, resulting in invalid Kotlin syntax.
Could you remove the trailing comma and add a regression test that generates and compiles a model with anyOf: [number, string]?
|
@AndreyVMarkelov thanks for reviewing the change. @dijkstrar please have a look at the findings when you've time |
…d i dont see value bumping it to kotlin 2.4.x
There was a problem hiding this comment.
All reported issues were addressed across 38 files (changes from recent commits).
Tip: Review your code locally with the cubic CLI to iterate faster.
View guided diff | Re-trigger cubic
|
Hi everyone, due to some off time i did not have the chance to look at your comments. First of all i want to thank you for taking the time to review these changes :) Thanks @AndreyVMarkelov for pointing out the trailing comma, and generating a test to verify the solution compiles :) I have fixed the trailing comma, and resultantly the test passes :) As for your comments @Picazsoo and @WonderCsabo , I am a bit in doubt as to how to continue.
Please let me know if you have any other direct suggestions as how to continue :) |
There was a problem hiding this comment.
9 issues found across 51 files (changes from recent commits).
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="modules/openapi-generator/src/main/resources/kotlin-spring/libraries/spring-boot/buildGradleKts.mustache">
<violation number="1" location="modules/openapi-generator/src/main/resources/kotlin-spring/libraries/spring-boot/buildGradleKts.mustache:47">
P1: The string literal on this line is never closed, so the generated `build.gradle.kts` is invalid Kotlin script and Gradle fails before the build starts. Close the quote.</violation>
</file>
<file name="samples/server/petstore/kotlin-springboot-modelMutable/build.gradle.kts">
<violation number="1" location="samples/server/petstore/kotlin-springboot-modelMutable/build.gradle.kts:39">
P1: This string literal is missing its closing quote, so `build.gradle.kts` will not parse and the sample build fails. Close the string as `"1.9.25"`.</violation>
</file>
<file name="samples/server/petstore/kotlin-springboot-reactive-without-flow/build.gradle.kts">
<violation number="1" location="samples/server/petstore/kotlin-springboot-reactive-without-flow/build.gradle.kts:39">
P1: The string literal is missing its closing quote, so this build script won't parse and the sb2 sample won't build. Close it: `extra["kotlin.version"] = "1.9.25"`.</violation>
</file>
<file name="samples/server/petstore/kotlin-spring-cloud/build.gradle.kts">
<violation number="1" location="samples/server/petstore/kotlin-spring-cloud/build.gradle.kts:40">
P1: This line has an unterminated string literal, so the Gradle build script will not compile. Close the string with a quote: `extra["kotlin.version"] = "1.9.25"`.</violation>
</file>
<file name="samples/server/petstore/kotlin-springboot-x-kotlin-implements/build.gradle.kts">
<violation number="1" location="samples/server/petstore/kotlin-springboot-x-kotlin-implements/build.gradle.kts:43">
P1: The string literal is never closed, so this build script will not parse. Close the quote: `extra["kotlin.version"] = "1.9.25"`.</violation>
</file>
<file name="samples/server/petstore/kotlin-springboot-include-http-request-context-delegate/build.gradle.kts">
<violation number="1" location="samples/server/petstore/kotlin-springboot-include-http-request-context-delegate/build.gradle.kts:39">
P1: This string literal is never closed, so the Gradle Kotlin DSL script will not parse and the sample will not build. Close the quotes on the value.</violation>
</file>
<file name="samples/server/petstore/kotlin-spring-default/build.gradle.kts">
<violation number="1" location="samples/server/petstore/kotlin-spring-default/build.gradle.kts:39">
P1: The string literal is never closed, so this Gradle Kotlin DSL script will not compile. Close the quote on the value: `extra["kotlin.version"] = "1.9.25"`.</violation>
</file>
<file name="samples/server/petstore/kotlin-springboot-source-swagger2/build.gradle.kts">
<violation number="1" location="samples/server/petstore/kotlin-springboot-source-swagger2/build.gradle.kts:39">
P1: This string literal is missing its closing quote, so the Gradle Kotlin DSL script will not parse and the sample build fails. Close the string with `"`.</violation>
</file>
<file name="samples/server/petstore/kotlin-springboot/build.gradle.kts">
<violation number="1" location="samples/server/petstore/kotlin-springboot/build.gradle.kts:39">
P1: The string literal on this line is never closed, so the Gradle build script won't parse. Add the missing closing quote.</violation>
</file>
Reply with feedback, questions, or to request a fix.
View guided diff | Re-trigger cubic
|
My position is that you should completely disregard all my previous comments. |
This change proposes to merge the kotlin version within the entire repository to Kotlin 2.4.20, as the currently used kotlin versions (1.x) are end of life.
**Note, bumping the kotlin version from 1.x to 2.4.20 is a major change, and should thus be considered and handled as a breaking change!! **
PR checklist
Commit all changed files.
This is important, as CI jobs will verify all generator outputs of your HEAD commit as it would merge with master.
These must match the expectations made by your contribution.
You may regenerate an individual generator by passing the relevant config(s) as an argument to the script, for example
./bin/generate-samples.sh bin/configs/java*.IMPORTANT: Do NOT purge/delete any folders/files (e.g. tests) when regenerating the samples as manually written tests may be removed.
Summary by cubic
Bumps Kotlin to 2.4.20 across the generator, templates, and regenerated samples to replace end-of-life versions, and swaps deprecated
values()forentriesin enum codegen with no behavioral change.jvm-volleyalso bumps the Android Gradle plugin to 8.5.2 and dropskotlin-stdlib-jdk8forkotlin-stdlib.kotlinOptions.jvmTargetwithcompilerOptions/JvmTargetin Gradle templates, using thekotlin { compilerOptions }block for spring-cloud.compile/testCompiletoimplementation/testImplementationfor Gradle 8.14.5, and bumps the shadow plugin to 8.1.1.kotlin-script-utilto 1.8.22, drops the undefinedjavaslang.match.PatternsProcessorprocessor, reworks test compilation aroundK2JVMCompiler, and updatesKotlinFileAssertfor the new compiler API.values()toentriesin enumfromValue/forValuemethods and modernizes generated code withrequireNotNull, string templates,URI,first()/isNotEmpty(), and cleaner equality checks.kotlinVersionfrom a generatedgradle.propertiesvia the settings file; Spring Boot 4 uses Gradle 8.14.5, while Spring Boot 2.x templates and samples are excluded, keep their original versions and wrapper pin, and don't inherit the property.Written for commit 8e006ac. Summary will update on new commits.