https://kotlinlang.org logo
#compiler
Title
# compiler
l

Lubomir Pisk

10/03/2023, 5:11 PM
Hello, I would like to use K2 compiler and I am solving issue: https://youtrack.jetbrains.com/issue/KT-55177 (Deprecate declaration of expect and actual counterparts of same class in one module) I need to add
-Xcommon-sources
CLI flag, but documentation is not clear. Can you help me with example solution for this problem? Thanks
d

dmitriy.novozhilov

10/03/2023, 6:58 PM
The most recommended way is to setup KMP project structure using kotlin-multiplatform gradle plugin If you want to experiment with some stuff and run the compiler manually, you can list sources from free args also in -Xcommon-sources flag But generally I don't recommend it because: 1. This flag will be deprecated soon in favour of -Xfragments cli flag 2. It's really hard to manage KMP flags manually
l

Lubomir Pisk

10/09/2023, 11:18 AM
I have expect class Driver in commonMain and actual class Driver in androidMain. How to setup parameter -Xcommon-sources for successful build?
d

dmitriy.novozhilov

10/09/2023, 11:19 AM
-Xcommon-sources=/path/to/file/with/expect/Driver
At the same time both files (with expect and actual classes) should be passed to
kotlinc
as free arguments
l

Lubomir Pisk

10/09/2023, 11:36 AM
And solution via gradle plugin?
d

dmitriy.novozhilov

10/09/2023, 11:42 AM
You just setup your project as KMP project (e.g. like in this guide), then call
./gradlew compileKotlinAndroidMain
(or anything else) and it just works