Michal Klimczak
02/02/2021, 9:56 PMkapt
and kaptKotlin
directories in generated/source
? When should I use one or the other? Can't really find anything about it. Dagger and moshi seem to generate to kapt
.
From my tests it seems that I need to manually tell gradle where to look for these files for either of these (via kotlin.srcDir("${buildDir.absolutePath}/generated/source/kapt/")
or kotlin.srcDir("${buildDir.absolutePath}/generated/source/kaptKotlin/")
. Yet it doesn't seem to be necessary for dagger etc.
If that makes any difference, I'm asking about kotlin multiplatform module.Michal Klimczak
02/02/2021, 10:00 PMkaptKotlin
is not properly marked as generated sources root in my android studio, but that might be unrelatedtddmonkey
02/03/2021, 11:33 AMtddmonkey
02/03/2021, 11:34 AMKapt can generate Kotlin sources. Just write the generated Kotlin source files to the directory specified by processingEnv.options["kapt.kotlin.generated"], and these files will be compiled together with the main sources.
https://kotlinlang.org/docs/reference/kapt.htmlMichal Klimczak
02/03/2021, 11:46 AMprocessingEnv.options["kapt.kotlin.generated"]
but the client of my processor still needs to explicitly use kotlin.srcDir("${buildDir.absolutePath}/generated/source/kaptKotlin/")
in his build.gradle.
On the other hand, moshi writes files to processingEnv.filer
and they end up in /generated/source/kapt/
, but they don't seem to require the kotlin.srcDir
to be explicitly set. When I do the same thing, kotlin.srcDir("${buildDir.absolutePath}/generated/source/kapt/")
is required. It's either a kotlin multiplatform thing or some kind of additional configuration that I cannot find.Michal Klimczak
02/03/2021, 3:11 PMtddmonkey
02/04/2021, 11:42 AM