New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Gradle's incremental build feature breaks annotation processing #298
Comments
Even if you tried the reflection glue (and I did on a side project last week), you will have issues if you change any code that should cause dagger code to generate different output (but not the component itself). It would be great to get someone that's familiar with the incremental compilation step, but as you said, I don't know (at least with my current set of knowledge about this) what we can do, and ideally this is something that could be solved at the build level so that every annotation processor would get this support. |
The best way would definitely be scanning the whole project again on incremental builds. As far as I know annotation processing can also scan |
For me, Hannes' suggestion to disable incremental dex didn't resolve the issue, which is why I had to disable incremental builds a little higher up the compilation chain, as suggested by this guy. Running Gradle with the following command line option caused Dagger's annotation processor to work properly again:
|
@aurae that's what Tor Norbye suggested to me as well and has worked for me. He said they're considering controlling the incremental flag for recognized processors in the future. |
I just talked with Tor and the next beta is going to make sure that incremental compilation is turned off for project that use Dagger, so it should at least be better in Android Studio. We're also going to raise the issue with the Gradle folks and see what they have to say. |
@gk5885 Shouldn't the solution apply to all projects using annotation processing? Or is this only a dagger-specific problem? |
It's not specific to Dagger, but many annotation processors are much simpler, and I think it could work with 1:1 mappings between input and output classes. |
@arriolac, I believe that they selected some list of annotation processors that they knew to have problems. I don't have any details, but I know that it was addressed for Dagger and some others. @tbroyer Some people from the Android tools side of things are going to discuss it in their regular sync with the Gradle people. I don't have any details, but they're going to report back when they talk it over. |
This is not a dagger-specific problem, it affects all annotation processors that uses getElementsAnnotatedWith(), some are fixable and some are not, for example, I had to do the following for an example project that I maintain:
@gk5885 So this is fixable on the annotation processor side but may have to rethink some use cases. I think turning it off for all annotation processors is not the right solution, maybe there needs a way for the annotation processors to declare themselves to require the knowledge of all existing files. apt plugin does support variables. |
Any updates on this? It doesn't look like Android Studio or Gradle are modifying their behavior when dagger is used. I am disabling incremental compilation explicitly in projects that use Dagger, but it would be nice if this would happen automatically. |
I would file those issues with the tools issue trackers, not with dagger. Not much we can do on that end. |
Sure - I asked because of @gk5885's comment from February 4th that mentioned that Android Studio would fix in an upcoming beta. Recent changes to gradle seem to have make it worse, but I only have anecdotal evidence. |
The sense that I get is that http://tools.android.com/tech-docs/new-build-system/2-5-alpha-gradle-plugin will be addressing this. Either way, there is little that Dagger can do here |
Gradle has this incremental build feature to speed up build times (especially useful on android). The problem with incremental builds is that the annotation processor will only run for those classes who has been changed and not for the whole project / source files.
In other words:
env.getElementsAnnotatedWith(...)
only returns annotated classes that has been changed since previous incremental build. This means that the whole project can't be evaluated and components can't be generated.I know it's not your fault! I think that there isn't much that you can do. The only thing that comes to my mind is to add some reflection code to glue all together at runtime, but who really wants that ...
I just have created this issue for others (mainly android developers) who struggle with this kind of issue as well. In android you can disable this incremental build feature as follows:
dexOptions { incremental false }
The text was updated successfully, but these errors were encountered: