eygraber
02/02/2024, 9:01 PMeygraber
02/02/2024, 9:09 PMTing-Yuan Huang
02/02/2024, 10:24 PMeygraber
02/04/2024, 2:31 AMeygraber
02/04/2024, 8:07 PMksp-companion
) is empty, and adds a directory containing common test code (common-companion
) to kotlin.srcDir
for commonTest
. A file in common-companion
(CompanionTest
) has code generated for it in ksp-companion
but it can't see that code. You can repro this by running ./gradlew assemble
on the branch I linked above.
This is a different scenario than my OP. I added it here in case they're related.eygraber
02/07/2024, 5:41 PMTing-Yuan Huang
02/07/2024, 6:29 PMTing-Yuan Huang
02/07/2024, 6:30 PMeygraber
02/07/2024, 6:48 PMeygraber
02/07/2024, 7:05 PMeygraber
02/07/2024, 7:15 PMeygraber
02/07/2024, 8:23 PMksp.useKSP2=false
(using Kotlin 2.0 Beta 3). However if I set ksp.useKSP2=true
then it stops working because no common main code is generated.eygraber
02/09/2024, 3:25 AMAngelo Salvade
11/26/2024, 6:52 AMKSDeclaration
is in platform specific code I use the following code:
private val Platforms = setOf(
"jvm", // JVM
"js", // JavaScript
"wasmJs", "wasmWasi",// WebAssembly
"macosX64", "macosArm64", // macOS
"iosArm64", "iosX64", "iosSimulatorArm64", // iOS
"linuxX64", "linuxArm64", // Linux
"watchosArm64", "watchosX64", "watchosSimulatorArm64", "watchosDeviceArm64", // watchOS
"tvosArm64", "tvosX64", "tvosSimulatorArm64", // tvOS
"mingwX64", // Windows
)
private fun KSDeclaration.isPlatformCode(): Boolean { // TODO: is there a better solution?
val filePath = containingFile!!.filePath
Platforms.forEach { platform ->
if (filePath.contains("/${platform}Main/") || filePath.contains("/${platform}Test/")) return true
}
return false
}
internal fun KSDeclaration.actual() = if (isPlatformCode()) "" else "actual "
I believe/hope there must be a more elegant solution for isPlatformCode().
Any ideas are welcome.