Repository navigation
Conversation
Since 3.2.1 the build inherits Spring Boot 4.2 and its Kotlin 2.4 compiler, so the published springdoc-openapi-starter-common jar advertises Kotlin metadata 2.4.0 and breaks compilation of any Kotlin 2.2 consumer (Spring Boot 4.0/4.1 apps) with 'Module was compiled with an incompatible version of Kotlin'. Pin apiVersion and languageVersion to 2.2 on the kotlin-maven-plugin of the only published module with Kotlin sources, so the emitted metadata stays at level 2.2.0 (as in 3.2.0) while the compiler itself continues to come from the managed Spring Boot version. Fixes springdoc#3458 Signed-off-by: Vadim Lazuk <vadimlazuk5@gmail.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #3458.
What happened
Release 3.2.0 was built against
spring-boot-starter-parent4.1.2 (Kotlin 2.2); 3.2.1 moved the parent to 4.2.0, whose managed Kotlin compiler is 2.4. The Kotlin compiler writes the metadata level into the published jar, so the 3.2.1springdoc-openapi-starter-commonjar advertises Kotlin metadata 2.4.0 and any consumer compiling with Kotlin 2.2 (Spring Boot 4.0/4.1 apps) fails with:What changed
springdoc-openapi-starter-common/pom.xmlonly —apiVersion2.2 andlanguageVersion2.2 on the module'skotlin-maven-plugin. That pins the emitted Kotlin metadata to level 2.2.0 (what 3.2.0 already shipped) while the compiler itself keeps coming from the Spring Boot version managed in the build. Nothing else changes: same module, same code, no dependency or source change. Modules without published Kotlin sources are untouched.One note on the fix:
apiVersionalone (which is what the issue suggested first) reaches the compiler but does not lower the emitted metadata version on Kotlin 2.4 — verified via the effective POM plusjavapon the rebuilt classes (@kotlin.Metadatastillmv=[2,4,0]). The metadata level followslanguageVersion, so both are pinned together;apiVersion2.2 additionally keeps the sources away from stdlib APIs newer than 2.2, which matters for real 2.2 consumers.Verification (RED → GREEN)
Consumer probe: a minimal Maven project with the Kotlin 2.2.20 toolchain and
springdoc-openapi-starter-commonas the only jar on the classpath carrying newer-than-2.2 Kotlin metadata (transitive Kotlin/Jackson-module deps excluded), compiling one trivial Kotlin file.RED — jar built from current
main(3.2.2-SNAPSHOT, no fix):Artifacts: classes in the unfixed jar carry
@kotlin.Metadata(mv=[2,4,0]).GREEN — jar rebuilt with this change:
Artifacts:
@kotlin.Metadatanowmv=[2,2,0]; the consumer compile succeeds with the 2.2.20 toolchain.No regression:
./mvnw -pl springdoc-openapi-starter-common test— 81 tests run, 0 failures, 0 errors (includes the module's Kotlin testsSpringDocKotlinxSerializationConfigurationTestandKotlinxSerializationRequiredPropertyCustomizerTest, which compile fine under the pinned language level).Scope guard
springdoc-openapi-starter-common-mcp, starters, tests) are not touched.