How can I leverage gradle's source sets to improve gradle build speed?

Viewed 131

Gradle's lack of incremental build support for annotation processing is a problem for build speeds and TDD. Libraries like Room can easily be put into its own module (leveraging compile time avoidance) for build speed improvements.

But what about for better incremental builds within a module like Dagger? Can Gradle's source sets be leveraged in any way to improve incremental build speeds?

Gradle recommended the following approach.

configurations {
    apt
    aptCompile
}
dependencies {
    apt 'com.google.dagger:dagger-compiler:2.8'
    aptCompile 'com.google.dagger:dagger:2.8'
}

sourceSets {
   processed {
       java {
          compileClasspath += configurations.aptCompile
       }
   }
   main {
       java {
          compileClasspath += processed.output
       }
   }
}

compileProcessedJava {
    options.annotationProcessorPath = configurations.apt
}

How can the same approach be taken with the android gradle plugin (and still support multiple flavors)? Would this approach be practical? Would we lose any Dagger features?

0 Answers
Related