My team has been reluctant to adopt dagger due to its cost in incremental build times, so until incremental annotation processing was implemented this wasn't really an option for us.
Now that this was implemented here, I decided to take a look at it and built the most recent version of master locally, and imported it into my team's project, and enabled the compile flag. I'm not even using dagger for anything, this is just enabling dagger to see how expensive it is before I add anything for dagger to do (I guess it's scanning the codebase for dagger annotations).
I found incremental ABI changes took the same amount of time with and without the compiler flag (4-6 seconds) per module I applied the dagger annotation processor in, so this is about a 50% increase in our incremental build times just to apply dagger to begin with. I find this surprising, shouldn't dagger only need to re-look at the file I changed? Why is it doing (what appears to be) the same amount of work compared to incremental processing being disabled?
I guess it's possible I'm doing something wrong, so I'm applying dagger via kapt like this in each of my module's build.gradle files:
kapt "com.google.dagger:dagger-compiler:LOCAL-SNAPSHOT"
And enabling the flag for incremental processing like this in my project level build.gradle file:
subprojects {
tasks.withType(JavaCompile) {
options.compilerArgs << "-Adagger.gradle.incremental"
}
}
The kaptGenerateStubsDebugKotlin task takes about 1 second, while the kaptDebugKotlin task takes about 4 seconds. This is pretty consistent, I did about a dozen trials of with and without the compiler flag and got pretty consistent results.
So I guess either there's a bug where the compiler flag doesn't work with kapt, I'm doing something wrong, or I'm just expecting too much out of the incremental processing.
kapt doesn't support incremental processing.
Make sure to vote on https://youtrack.jetbrains.com/issue/KT-23880.
@JakeWharton
is kapt supported now?
with this
afterEvaluate {
extensions.findByName('kapt')?.arguments {
arg("dagger.gradle.incremental", "enabled")
}
}
@ghost no! Subscribe to https://youtrack.jetbrains.com/issue/KT-23880 to be notified when it is supported.
@ghost meanwhile, if build time is a concern, you could disable generated code format and try to modularize your project.
afterEvaluate {
extensions.findByName('kapt')?.arguments {
arg( "dagger.formatGeneratedSource", "disabled" )
}
}
It's coming in 1.3.30! https://youtrack.jetbrains.com/issue/KT-23880
Shall we re-open this?
Most helpful comment
It's coming in 1.3.30! https://youtrack.jetbrains.com/issue/KT-23880