https://kotlinlang.org logo
#build-tools
Title
# build-tools
e

Eugen Martynov

12/13/2017, 5:50 PM
Does kapt support incremental builds?
g

gildor

12/13/2017, 6:05 PM
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

Eugen Martynov

12/13/2017, 6:14 PM
I completely missed that annotation processing is not incremental with gradle https://github.com/gradle/gradle/issues/1320
Thanks for pointing out
g

gildor

12/13/2017, 6:17 PM
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

Eugen Martynov

12/13/2017, 6:19 PM
ok, so I consider annotation processing an developer evil 🙂
g

gildor

12/13/2017, 6:19 PM
The Good, the Bad and the Ugly 🙂
e

Eugen Martynov

12/13/2017, 6:20 PM
Why it was never on the radar? AP is standard since java6
g

gildor

12/13/2017, 6:24 PM
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

Eugen Martynov

12/13/2017, 6:26 PM
Thanks!
Thanks for the discussion and pointing out to the problem and reference for the solution
g

gildor

12/13/2017, 6:27 PM
No solution yet unfortunately but I want to believe 👽
Looks like we can already try something
g

gildor

12/13/2017, 6:36 PM
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

Eugen Martynov

12/13/2017, 6:40 PM
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

gildor

12/13/2017, 6:41 PM
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

Eugen Martynov

12/13/2017, 6:43 PM
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

gildor

12/13/2017, 6:48 PM
Java incremental compilation disabled if you have AP
s

stepango

12/14/2017, 5:06 AM
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

gildor

12/14/2017, 5:07 AM
@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
4 Views