I have gone through many steps to refine our build system (those and more). Later, I read this official blogpost that claims that build times are improved 5-10x with incremental builds in Gradle 3.4. Indeed, our incremental builds were not working, because we used annotationProcessors. Since Gradle 4.7 annotationProcessors can opt-in to be compatible with incremental builds. I have gone through many dependency updates to activate incremental builds with annotationProcessors that support it.
Through various configurations and improvements I was able to reduce our build time (prebuilt) from ~30s to ~19s. Based on the incremental build blogpost I was assuming that I could further reduce build times to ~5s.
Unfortunately, with incremental builds it only came down to ~15s. Using --profile
and --info
I tried to further diagnose the issue. Only exctracting the gradle task compileDevDebugJavaWithJavac
it shows that the compilation step went from ~16s to ~12s.
Incremental compilation of 476 classes completed in 12.51 secs.
It appears to me that this is too slow for a single line change, and it doesn't nearly reflect what Gradle claims for incremental builds. I specifically tried to change files with few dependencies and I know that public constants trigger full rebuilds. What else can cause an incremental build for only a single file to be that slow?
I also tried to enable the experimental feature
android.enableSeparateAnnotationProcessing=true
which does work and splits up my build into two compile steps
compileDevDebugJavaWithJavac 6.777s
processDevDebugAnnotationsWithJavac 6.104s
I was hoping that in conjunction with
org.gradle.parallel=true
Both tasks might run in parallel and almost half the build time. But apparently parallel processing does not work here, or does it?
What else can be done to increase build times of very small changes?
Edit: I found out that the main problem is that we have too many class dependencies and it always triggers the compilation of 476 classes (see this question). As I don't expect to resolve enough class dependencies in our legacy code: my question still stands. Can the project can enableSeparateAnnotationProcessing
be parallelized or is there any other configuration?