Open andrew-k-21-12 opened 2 years ago
Would you mind sharing the full error message and stacktrace? This error might be caused by kotlin(jvm)
with kotlin(js)
. Can you check whether the error is still there without applying ksp?
@ting-yuan, The issue still reproduces. Even with the latest versions for Kotlin JVM, JS and KSP plugins - added the corresponding reproduce commit: https://github.com/andrew-k-21-12/ksp-reproduce/commit/071631d0049d880a31c4b4663024ab33bdc1bf94.
Would you mind sharing the full error message and stacktrace?
Attaching as a file: stacktrace.txt.
Can you check whether the error is still there without applying ksp?
The error disappears when removing id("com.google.devtools.ksp") version "1.7.20-1.0.8"
from build.gradle.kts
. Also, it helps to switch the compiler from IR
to LEGACY
or use the multiplatform project structure instead. All of these variants are stated in the corresponding commits here.
This seems to still be an issue. Using the multiplatform structure doesn't seem to work for me with JS using IR. I get a litany of unresolved references when not using the legacy compiler.
There is any update on this?
Seems like switching to the kotlin-multiplatform
plugin is the right direction according to the Kotlin 1.9.0 release notes. So the issue is not actual (at least for me) anymore and can be closed possibly.
Hey @andrew-k-21-12, can you confirm that with the KMP plugin, you're able to use KSP to generate/target code for K/JS?
Thanks!
Steps to reproduce:
Create a new Kotlin/JS React application: everything compiles and works - https://github.com/andrew-k-21-12/ksp-reproduce/commit/59d656cd4bed8f5618e479650238d81afc040915.
Add the
com.google.devtools.ksp
plugin for the application and try to sync Gradle - the following error doesn't allow to do it: Caused by: java.lang.IllegalStateException: You already registered Kotlin/JS target with another compiler: legacy. This state is committed here - https://github.com/andrew-k-21-12/ksp-reproduce/commit/42222f9b3a0ecc760d31e92201f7a334c2b5d971.Possible workarounds:
Switching into the
LEGACY
compiler: doesn't seem like a suitable solution - https://github.com/andrew-k-21-12/ksp-reproduce/commit/c752e6eeae4fbc8cbe7dc485ec843d32ed2c2c6b.Migrating from the
js
into themultiplatform
plugin: works fine, but seems like unnecessary friction a little bit - https://github.com/andrew-k-21-12/ksp-reproduce/commit/c7b01d9f19036a81c13c3eb6a03758c47407aa69.