groovy / groovy-android-gradle-plugin

A Gradle plugin to support the Groovy language for building Android apps
Apache License 2.0
850 stars 116 forks source link

Document annotation processing #105

Closed WonderCsabo closed 8 years ago

WonderCsabo commented 8 years ago

I managed to make "annotation processing" work on a Groovy Android Gradle project.

I updated the Android Gradle Plugin from 1.2.3 to 1.5.0 and the Groovy Android Gradle plugin from 0.3.6 to 0.3.9, and annotation processing no longer works. The processor is initialised, but no processing rounds are started.

Issue originally opened against the android-apt plugin.

AndrewReitz commented 8 years ago

Could you provide a sample, or even better write a functional test that is not working? I am currently working on an example project and it has been working fine.

WonderCsabo commented 8 years ago

I linked my example project in the OP. :wink:

AndrewReitz commented 8 years ago

You don't have gradle set to run the annotation processor.

androidGroovy {
  options {
    configure(groovyOptions) {
      javaAnnotationProcessing = true
    }
  }
}
WonderCsabo commented 8 years ago

@pieces029 This does not help, and actually this is not necessary, because the android-apt plugin already sets that property.

But i added that snippet and it is still not working. I reverted to Groovy Android Gradle Plugin 0.3.6 and Android Gradle Plugin 1.2.3, and the same project immediately worked, so i am pretty sure something went wrong in the newer plugin versions.

AndrewReitz commented 8 years ago

Here is what I'm doing for databinding, which uses annotation processing. https://github.com/pieces029/groovy-android-data-binding/blob/master/build.gradle The Apt Plugin didn't work until I set javaAnnotationProcessing = true I don't think the skipJavaC is required, I just wanted groovy to compile everything.

I am currently working on a dagger sample, which does not use apt plugin and everything is also working fine, as long as I have javaAnnotationProcessing = true.

This sounds more like a problem with the apt plugin if anything, although javaCompile is still finalized by groovy compile so that should all be working correctly too.

AndrewReitz commented 8 years ago

Oh, you need to have the groovy plugin before the apt plugin :)

Not sure why the order matters, but it does.

AndrewReitz commented 8 years ago

Opening as a ticket for adding documentation around annotation processing.

WonderCsabo commented 8 years ago

@pieces029 thanks, changing the plugin order indeed works!

hvisser commented 8 years ago

Not sure why order matters, since android-apt uses project.afterEvaluate(). I guess Gradle will still order that call in some way.

AndrewReitz commented 8 years ago

Added in #115