ZacSweers/auto-service-ksp

Didn't find classes in another souceSet ( android)

kingori opened this issue · 4 comments

I'm not sure this bug is occured by auto-service-ksp or auto-service or kotlin.

I have multiple @AutoService annotated classes in multiple sourceset in same module. But services file contains lists of only one sourceset classes.

for example, I have files like this and all files have @AutoService(mypkg.MyTarget) annotions.

my_module/ src/ sandbox / mypkg / TargetA.kt
my_module/ src/ main / mypkg / MyTarget.kt
my_module/ src/ main / mypkg / TargetB.kt
my_module/ src/ main / mypkg / TargetC.kt

then, generated mypkg.MyTarget contains only TargetB , TargetC.

Is there any solution for this problem?

Sorry I don't understand

@ZacSweers ok, I'll try to write again :)

A module in an Android project can have multiple source sets. However, when I used auto-service-ksp to annotate classes, the resulting file in META-INF/service only contained classes from one source set.

for example, if my module name is my_module and my auto-service target class is MyTarget , I can wirte classes like below.

//my_module/src/debug/pkg_name/ TargetA.kt
package pkg_name
@AutoService( MyTarget)
class TargetA { ... }

//my_module/src/main/pkg_name/ TargetB.kt
package pkg_name
@AutoService( MyTarget)
class TargetB { ... }

//my_module/src/main/pkg_name/TargetC.kt
package pkg_name
@AutoService( MyTarget)
class TargetC { ... }

In this case, I expect the following content to be generated in the META-INF/services/MyTarget file.

pkg_name.TargetA
pkg_name.TargetB
pkg_name.TargetC

but generated file only contains class names from one source set like below. Class defined in another source set is omitted.

pkg_name.TargetB
pkg_name.TargetC

I used kotlin 1.8.21 , ksp 1.8.21-1.0.11.

can you make a minimally reproducing sample project and link/attach it here?

@ZacSweers i've made a sample project. https://github.com/kingori/ksp_test

Anyway, I think this is bug of android gradle plugin 7.3.1 because if I update plugin, this problem is gone. So it's not issue of auto service ksp. Sorry for wrong issue report.