https://kotlinlang.org logo
#kapt
Title
# kapt
u

uhe

01/19/2018, 8:59 AM
So has anyone played around with
kapt { useBuildCache = true }
? We're relying heavily on annotation processing and I think this could help speed up our build times significantly. However, I'm a bit afraid we'll end up with broken apps half the time...
4
y

yan

01/22/2018, 6:04 PM
@h0tk3y ^^ FYI
h

h0tk3y

01/22/2018, 6:37 PM
Well, caching kapt will work fine if the annotation processors that you use do not produce anything apart from Java/Kotlin sources and classes, all in the pre-defined directories (anything outside them won't be stored into the cache), and do not use anything other than the sources and the dependencies as inputs (we add Android layouts as the sources as well, it's fine for APs to use them). If you know about a particular annotation processor that uses or produces anything else, then make sure you add those things as inputs/oitputs to the kapt tasks with the Gradle's runtime inputs/outputs API, and again, that will work just fine. The annotation processors should be stable as well (i.e. produce the same outputs when called consecutively on the same inputs). I'd suggest trying to use the cache, clean the project and make Gradle load the results from cache to see how it works and whether it leads to the same build results (you may even compare the build results file-by-file).
u

uhe

01/22/2018, 9:06 PM
sounds like a plan, thanks!
16 Views