Annotation processing on external sources jar

I’m trying to let an annotation processor process sources in a jar instead of sources in the project itself. However, the annotation processor doesn’t pick up the sources from the jar. Is this possible?

In build.gradle, I use:

implementation "com.example:lib:1.0.0"
kapt "com.example:lib:1.0.0:sources"

I tried several variants of this (add and remove :sources), without luck.

I don’t think this is possible. Kapt only works on the source files you are compiling.
Also I’m not sure how you think your gradle script is working. kapt "com.example:lib" is the reference to the annotation processor to use, not the sources the annotation processor works on.

Maybe you can describt what you are trying to achieve so we can suggest an alternative.

My use case is this:
I have a set of data classes in that jar. One of them is annotated with @Annotation(“file name”) where “file name” is the name of a config file. The config file is local to the project, so that config can be different between projects.

What are you trying to do? Just read the name of this file? You should be able to do this using normal reflection. Annotation processing is only required if you want to read information from code that is not yet compiled.