gradle-checker-framework-plugin
gradle-checker-framework-plugin copied to clipboard
Not working well with generated source from another processor
Try to use this plugin in my android project where I also use Glide image library.
Glide generates Java source (GlideApp) dynamically which is used in app, however plugin is unable to find that as source, if i don't use checker app complies normally
/Users/xxx/work/code/app/src/main/java/com/yyy/MainActivity.java:113: error: cannot find symbol import com.yyy.GlideApp; ^ symbol: class GlideApp location: package com.yyy
Am I missing something?
Is that the whole error? Can you provide more details? Maybe this has been tested with Java and Android?
The problem is that the checker plugin overwrites both the processor path and which processors to use. As a result no other annotation processors (e.g. the one from Glide) will run.
@oehme Thanks for the explanation. Should I be appending these on instead of overwriting?
I think so. But there is a conceptual problem: The plugin sets the -processor
option based on the checkers selected in the extension. That will deactivate all other processors. I'm not aware of a way to solve that dilemma using javac's arguments.
Maybe running all checkers is a better default and you could ask users to use -processor
themselves if they really want to filter, keeping in mind the effect that has on other processors?
@oehme I will try to look into that. I based this plugin on this Checker framework documentation here: https://checkerframework.org/manual/#android-gradle.
Yeah that document assumes no other annotation processors.
I might need to try the better default or update the README.md.
I just looked at their code base. They don't have any descriptors for auto discovery (intentionally). So what you can do is write a task that generates a file called META-INF/services/javax.annotation.processing.Processor
, list the checkers in there and then put that file into a folder and add that folder to the processor path of the compile task. Then Gradle and javac will pick those processors up during discovery without overwriting others.
Also while you're changing it - Passing the -processorpath option as a string is deprecated, because we have a DSL method (options.annotationProcessorPath) for it. That option will work properly with up to date checking and caching. The same is true for the bootClasspath.
+1 for this. Doesn't work in combination with Lombok
There is another way since Gradle 4.6: use annotationProcessor
and testAnnotationProcessor
configurations
@grv87 Can you make a PR? @oehme might be able to take a look?
@jaredsburrows, I've stopped using this plugin, at least for now. IIRC, my code was OK, but checker-framework didn't work for my case. But no warranties. If you are ready to fix any issues that can arise during review, feel free to open PR with my code by yourself.
I am currently not using this on any projects. I am open to pull requests.