Daniel Pejcinovski
03/04/2025, 1:03 PMbuild/generated/ksp/metadata/common/kotlin/MyGeneratedFile.kt
and an additional in build/generated/ksp/jvm/jvmMain/kotlin/MyGeneratedFile.kt
.
This is fine and good, but now I want to use the generated files, and I just can't figure out how to add it as a dependency or source sets.
I'm using the following to add it as a dependency:
dependencies {
add("kspCommonMainMetadata", project(":myProcessors"))
add("kspJvm", project(":myProcessors"))
add("kspJvmTest", project(":myProcessors"))
}
Again, this works, and is what gets me the files when I build.
However, I use Kotlin MPP specific annotations when generating the files, such as @JsExport
and @JsStatic
, which aren't processable on the JVM platform and I get Declaration annotated with '@OptionalExpectation' can only be used in common module sources
errors.
If I remove the KspJvm
and KspJvmTest
lines I only get unresolved
errors and the processor does not run on building.
There is something I'm just not getting here, any ideas?Jason Dusek
03/06/2025, 1:59 AMDaniel Pejcinovski
03/06/2025, 8:01 AMJason Dusek
03/06/2025, 4:23 PMJason Dusek
03/06/2025, 4:23 PMCodeGenerator
, like this:
val file = codeGenerator.createNewFile(...)
Jason Dusek
03/06/2025, 4:24 PMJason Dusek
03/06/2025, 4:24 PMval file = codeGenerator.createNewFile(Dependencies(, file1, file2, ...), ...)
Jason Dusek
03/06/2025, 4:26 PM.containingFile
that you can use for this purpose.Daniel Pejcinovski
03/18/2025, 6:58 AMDaniel Pejcinovski
03/18/2025, 7:10 AM