glureau
11/08/2024, 12:25 PMYuang Qiao
11/08/2024, 2:54 PMMarco Signoretto
12/05/2024, 1:52 PMandroidUnitTestDebug
and commonTest
, please check you -Xfragment-sources options.` ( which make sense ) Does anyone knows if we will ever get ksp generation for commonTest?Yuang Qiao
12/05/2024, 8:40 PMcommonTest
.
First of all. Before K2, we can generate code for commonTest
, but the code is in the path of the specific source set, e.g. macosX64Test
. We can run the test code in commonTest
, but the IDE can't find the generated code (there would be some errors.
After K2, we can generate the code with the same way, but we can't run the test code correctly, due to the compiler can't find the generated code now.
Solution: We can just create a new code path, and move the code from commonTest
into it. Then, add this path to the final source sets (like jvmTest
, macosTest
), rather than the abstract source sets (like commonTest
, nativeTest
). For example, add the code path src/commonTestCode/kotlin
to jvmTest
:
jvmTest {
kotlin.srcDirs("src/commonTestCode/kotlin", path)
}
Everything works. The last thing that need to mention is don't use KSP2 now. This way doesn't work for KSP2!
You can refer to my project (https://github.com/ctripcorp/SQLlin/tree/main/sqllin-dsl) to find more details.glureau
12/06/2024, 7:59 AMglureau
12/06/2024, 8:04 AMcg.sourceToOutputs.put(commonTestFile, sourceFiles)
which bypass the security implemented when generating a file the normal way with ".." in the path. I'm not recommending it but that's maybe why my hack did work with cache 🤷Yuang Qiao
12/06/2024, 10:29 AMnativeTest
and macosX64Test
.