Here’s a small Gradle plugin that helps out if you have a project that includes an annotation processor. There are two use cases for this plugin:1. You have a processor that has a compiler part and an api part, you don’t want to get the compiler in your app. For this purpose the plugin sets up an apt
2. Your annotation processor produces source which you want to reference in Android Studio. By default these kinds of projects build
fine in Android Studio, but the generated source isn’t on any source path in Android Studio so you might get errors there. The plugin will add the generated source to a source set so that AS will recognize it. This is also true for the first case btw; if the processor generates source, it will be added to the source set for the current flavor.
This is all based of a script that I’ve been using https://bitbucket.org/qbusict/android-gradle-scripts/src/60394ba8f5efa64badb17c9388f38b89f09c5d9a/annotations.groovy?at=default but it got a bit cumbersome to check out the script for each project and I thought providing it as a plugin might be useful for others as well.
One thing that is still missing is the option for passing in arguments to the annotation processors, when I have the need for it I’ll add it, but pull requests are welcome.
It’s live on Maven Central so easy to add to your build if you need it.
More info and source is here: https://bitbucket.org/hvisser/android-apt
View this post on Google+