As shown in #963, this repository's multiplatform example generates identical code for all source sets, resulting in "Redeclaration" compiler errors once dependencies are set up correctly. While this example can be fixed by generating code for the commonMain source set only, this will not work with projects requiring separate code sets generated for different source sets.
OliverO2/kotlin-multiplatform-ksp contains an example project where this problem has been solved via source set detection:
https://github.com/OliverO2/kotlin-multiplatform-ksp/blob/214eef9e529ca3dae8a6e38123790b4795302969/symbol-processor/src/jvmMain/kotlin/QualifiableProcessor.kt#L37-L38
https://github.com/OliverO2/kotlin-multiplatform-ksp/blob/214eef9e529ca3dae8a6e38123790b4795302969/symbol-processor/src/jvmMain/kotlin/QualifiableProcessor.kt#L55-L56
As there seems to be no reliable API providing the required information on input and output source sets, the solution is unstable.
In addition, the output source set is only detected via the codeGenerator's generated file path, which makes it unsuitable for collecting information before deciding on code generation.
Would it seem feasible for a future KSP release to provide information on input and output source sets via the SymbolProcessorEnvironment or the Resolver?
As shown in #963, this repository's multiplatform example generates identical code for all source sets, resulting in "Redeclaration" compiler errors once dependencies are set up correctly. While this example can be fixed by generating code for the
commonMainsource set only, this will not work with projects requiring separate code sets generated for different source sets.OliverO2/kotlin-multiplatform-ksp contains an example project where this problem has been solved via source set detection:
https://github.com/OliverO2/kotlin-multiplatform-ksp/blob/214eef9e529ca3dae8a6e38123790b4795302969/symbol-processor/src/jvmMain/kotlin/QualifiableProcessor.kt#L37-L38
https://github.com/OliverO2/kotlin-multiplatform-ksp/blob/214eef9e529ca3dae8a6e38123790b4795302969/symbol-processor/src/jvmMain/kotlin/QualifiableProcessor.kt#L55-L56
As there seems to be no reliable API providing the required information on input and output source sets, the solution is unstable.
In addition, the output source set is only detected via the
codeGenerator's generated file path, which makes it unsuitable for collecting information before deciding on code generation.Would it seem feasible for a future KSP release to provide information on input and output source sets via the
SymbolProcessorEnvironmentor theResolver?