https://kotlinlang.org logo
#android
Title
# android
s

Sangeet

07/31/2018, 12:44 PM
I want to know whether kapt support incremental build and dagger supports that ?
g

gildor

07/31/2018, 1:16 PM
No
This is not even a problem of Kapt. Jsr269 doesn't provide any facilities for incremental compilation
But guys from Gradle have experimental API that provides such tools and works for jsr269 compatible annotation processors, but requires integration from annotation processors For example this is a thread about this on Dagger issue tracker https://github.com/google/dagger/issues/1120
s

Sangeet

07/31/2018, 1:58 PM
@gildor Okay. So even android data binding doesn’t support that. The problem is in multi module project, it’s kind of increasing build time.
g

gildor

07/31/2018, 1:59 PM
Nobody supports this, because technology itself doesn't provide way to support it
Actually DataBinding library has pretty powerful incremental part of compiler with caches and so on, but they still depend on jsr269 and cannot make compilation completely incremental
DataBinding team also works on this problem and probably implement solution from Gradle (people from Google also work together with Gradle on this project)
s

Sangeet

07/31/2018, 2:07 PM
Okay got it. The problem I figured it is that kapt is not getting cached. If you change in some class which doesn’t have annotations, kapt for that module is getting triggered and it’s taking lot of time.
g

gildor

07/31/2018, 2:08 PM
No, it's not the source of the problem
You cannot process classes only with annotations, because annotation processor can generate code even based on classes without annotations or not for classes at all. Like in case of DataBinding, you generate code based on xml layouts
In case of multimodule project situation is actually better, because if you have good graph of modules and properly configured annotation processors that isolated by a single module, you will get recompilation only changed module instead of whole project
And as I said, it's not only a problem of KAPT, but also APT from Java, has exactly the same problem
s

Sangeet

07/31/2018, 2:20 PM
Okay. So I think it’s better to not use any annotations at all.