Skip to content
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

Kotlin 2 support #80

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open

Kotlin 2 support #80

wants to merge 7 commits into from

Conversation

glureau
Copy link

@glureau glureau commented Nov 13, 2024

K2 doesn't support to have generated code in jvmTest + commonTest. Here is an attempt to move those files in commonTest instead of playing with sourceSets.

The move is done just after files are written. Due to KSP incremental building implementation, we need to keep files in jvmTest, so to avoid duplication we're copying the content in commonTest and empty the original jvmTest files.

Versions doesn't match your internal gradle settings plugin, feel free to adjust that draft ;)

Thanks for your time! You rocks guys!

Note that there's no official way to record a generated file in commonTest. Also some local tests shown that those files are updated only when required so it looks promising... (as a workaround until KSP 2.1)
…keProvider (as a expect/actual declaration is actually not a symbol duplication).
@flipper09112
Copy link

This PR is for fix this problem #78 ?

@glureau
Copy link
Author

glureau commented Nov 21, 2024

Yep, also I can't guarantee it'll always work well: What I'm doing is moving files from jvmTest to commonTest, and I record them in KSP CodeGeneratorImpl, which is not supposed to be used that way. CodeGeneratorImpl is checking explicitely that a file is written in the current generation directory (jvmTest), I bypass that by loading the "internal" KSP lib and directly add in the generated file mutable map. As a result, it's likely to have gradle cache inconsistency, you may have to "./gradlew clean" to remove previously generated files when code is changing.

I'm running that in our KMP app, roughly 150k lines, no problem on CI, but we notice a few edge cases when doing incremental builds with wrong cache invalidation (and a build error when a FakeProvider is setup on commonMain on a class without empty constructor).

TLDR: try and tell me if you see something weird :)

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

Successfully merging this pull request may close these issues.

2 participants