title: How can I leverage gradle's source sets to improve gradle build speed?
body: <p>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.</p>
  
  <p>But what about for better incremental builds <em>within a module</em> like Dagger? Can Gradle's source sets be leveraged in any way to improve incremental build speeds?</p>
  
  <p>Gradle recommended the <a href="https://blog.gradle.org/incremental-compiler-avoidance#incremental-compile-with-annotation-processors" rel="nofollow noreferrer">following approach</a>.</p>
  
  <pre><code>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
  }
  </code></pre>
  
  <p>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?</p>