Does kapt support incremental builds?
# build-tools
e
Does kapt support incremental builds?
g
Annotation Processing is not incremental, not only with Kapt. Same sitation with apt and Java. Kapt have some incremental steps (like stubs generation), but in general AP is not incremental
There is a project from Gradle and Google that wants to priovide api for AP authors to support incremental annotation processing https://github.com/gradle/incap Detailed description of Milestone 1 https://docs.google.com/document/d/1CXNfKmPx9hqfnGWic3F9sKHQ6T8ImDVxnXfkvWYqwxg/edit
Under the hood AP still can have own incremental code generation, but without integration with build system it’s hard to support and it’s not flexible enough
e
I completely missed that annotation processing is not incremental with gradle https://github.com/gradle/gradle/issues/1320
Thanks for pointing out
g
Not only with Gradle. Java JSR-269 provides nothing for support of incremental AP, so it’s completely build system feature that should be integrated to AP library.
e
ok, so I consider annotation processing an developer evil 🙂
g
The Good, the Bad and the Ugly 🙂
e
Why it was never on the radar? AP is standard since java6
g
I suppose nobody used this so intensive as today.
also java compilation was not incremental (it’s build tools feature, not javac itself)
Also I think Android developers pushed that a lot, because AP is super popular on Android because of many reasons
e
Thanks!
Thanks for the discussion and pointing out to the problem and reference for the solution
g
No solution yet unfortunately but I want to believe 👽
Looks like we can already try something
g
Yes, it’s proof of concept. Problem that to achieve incremental AP all your AP should support that. In my Android case two biggest thing is Databinding and Dagger
e
We also use them, but at least Butterknife and autovalue are incremental
so some small gain in build speed
or it will re-run everything in this case?
g
you should get some gain I suppose, just because AP generates less code, but think it’s minor part, biggest one is incremental java/kotlin compilation that cannot be achieved without incremental AP
e
Ok, I need to read how incremental java compilation in gradle is implemented
I was thinking it can detect what file is changed
so if less files are re-generated then less compile time is needed
g
Java incremental compilation disabled if you have AP
s
Only way of getting incremental AP is breaking app into small modules, since AP would be running only inside changed module build speed would be much faster👍
g
@stepango Unfortunately doesn’t work with Dagger Subcomponents and Data Bindings And it’s not incremental, but yeah, at least you can compile only one module and modules that use it
btw Incap Milestone 1 already have PR to Gradle - https://github.com/gradle/gradle/pull/3434