Skip to content

Kotlin compilation error with spring-cloud-function 4.2.0- #1218

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
bnasslahsen opened this issue Dec 7, 2024 · 11 comments
Closed

Kotlin compilation error with spring-cloud-function 4.2.0- #1218

bnasslahsen opened this issue Dec 7, 2024 · 11 comments
Labels
Milestone

Comments

@bnasslahsen
Copy link

bnasslahsen commented Dec 7, 2024

Describe the bug
Kotlin compilation error with spring-cloud-function 4.2.0

Versions of the framework:

  • Spring Boot 3.4.0
  • Spring Cloud: 2024.0.0
  • Kotlin: 1.9.25
  • Java: 17

Sample
To reproduce:

  1. Generate the project from https://start.spring.io/#!type=maven-project&language=kotlin&platformVersion=3.4.0&packaging=jar&jvmVersion=17&groupId=com.example&artifactId=demo&name=demo&description=Demo%20project%20for%20Spring%20Boot&packageName=com.example.demo&dependencies=web,cloud-function
  2. unzip and compile the project:
./mvnw compile

Current behavior
Compilation error:

[ERROR] Failed to execute goal org.jetbrains.kotlin:kotlin-maven-plugin:1.9.25:compile (compile) on project springdoc-openapi-starter-common: Compilation failure
[ERROR] /opt/repository/org/springframework/cloud/spring-cloud-function-context/4.2.0/spring-cloud-function-context-4.2.0.jar!/META-INF/spring-cloud-function-context.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 2.1.0, expected version is 1.9.0.
[ERROR] -> [Help 1]

Expected behavior
No compilation error

Added minimal reproducer project just in case:
demo3.zip

@olegz
Copy link
Contributor

olegz commented Dec 9, 2024

We do not specify Kotlin version anywhere in s-c-function, so it is pulled transitively.
Yes I was able to reproduce the issue with your reproducer (thank you) and it appears that something has changed upstream (perhaps in boot) since if you upgrade cloud version to 2024.0.1-SNAPSHOT, everything compiles just fine.

Please let me know, so I can close this issue

@spencergibb
Copy link
Member

See #1015. In my tests, I see the kotlin-maven-plugin using a 2.1.0 plugin. There might be some times it gets 2.1.0 and other times it doesn't.

spencergibb added a commit that referenced this issue Dec 9, 2024
@olegz
Copy link
Contributor

olegz commented Dec 10, 2024

Seems like it is indeed random, so we need to be explicit about it. . .
Thank you @spencergibb for adding it - 0a43fc9

@bnasslahsen
Copy link
Author

Wonderful, thanks @olegz and @spencergibb!
Looking forward to 4.2.1—maybe it’ll arrive just in time for Christmas!

@johnnymo87
Copy link

Hi @olegz is there a snapshot available anywhere that contains this fix? I'm unable to upgrade to Spring Boot 3.4.x until I can get access to this fix. 🙏

@10marianosikJoz
Copy link

Hi @olegz is there a snapshot available anywhere that contains this fix? I'm unable to upgrade to Spring Boot 3.4.x until I can get access to this fix. 🙏

I have same issue.

@StefanLobbenmeierObjego
Copy link

StefanLobbenmeierObjego commented Jan 28, 2025

issue seems to be introduced from 4.1.4 onwards, here is what I tested

  • spring-cloud-function-context-4.1.3.jar ✅
  • spring-cloud-function-context-4.1.4.jar ❌
  • spring-cloud-function-context-4.1.5.jar ❌
  • spring-cloud-function-context-4.2.0.jar ❌
  • spring-cloud-function-context-4.2.1.jar ✅

@spencergibb
Copy link
Member

Can you try 4.2.1?

@StefanLobbenmeierObjego
Copy link

StefanLobbenmeierObjego commented Jan 28, 2025

4.2.1 works on my machine, edited my comment for clarification.

There is no version of org.springframework.cloud:spring-cloud-dependencies yet that includes that release so I had to specify the version manually

	val cloudStreamVersion = "2024.0.0"
    implementation(platform("org.springframework.cloud:spring-cloud-dependencies:$cloudStreamVersion"))
    testImplementation(platform("org.springframework.cloud:spring-cloud-dependencies:$cloudStreamVersion"))
    implementation("org.springframework.cloud:spring-cloud-function-context:4.2.1")
    implementation("org.springframework.cloud:spring-cloud-starter")
    implementation("org.springframework.cloud:spring-cloud-starter-stream-kafka")

@spencergibb
Copy link
Member

There is no version of org.springframework.cloud:spring-cloud-dependencies yet that includes that release so I had to specify the version manually

That is correct, it was specifically released outside the release train, in part, for this issue.

@matthew-js-porter
Copy link

Are there plans to backport the fix to 4.1?

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

No branches or pull requests

7 participants