title: multi-module project with dagger: Component depends on more than one scoped component
body: <p><em>Note: There seems to be a number of questions about the similar issue but this one is more specific to multi-module app and previously suggested solutions do not work</em></p>
  
  <p>I'm starting a multi-module project with one module (Android studio module) for each architectural layer (i.e., Data, Domain, Presentation) and using Dagger 2 to provide dependency injection across the app. Currently I have one Dagger Component for each module which exposes dependencies from each module to other modules. A simplified version looks like this:</p>
  
  <pre><code>@Singleton
  @Component(modules=[DataModule::class])
  DataComponent {
     fun tokenRepository(): TokenRepository
     fun jobRepository(): JobRepository
  }
  
  @Singleton
  @Component(modules=[DomainModule::class])
  DomainComponent {
     fun somethingSingleton(): Something
  }
  
  // In Presentation Module
  @PerApp
  @Component(dependencies = [DataComponent::class, DomainComponent::class])
  AppComponent {
     fun tokenRepository(): TokenRepository
     fun jobRepository(): JobRepository
     fun somethingSingleton(): Something
  }
  </code></pre>
  
  <p>I got an error saying Dagger component is not allowed to depend on multiple scoped components. However since both Data and Domain components need to provide singletons (like token repository), I have to use something like <code>@Singleton @Provide fun getTokenRepository...</code> in <code>DataModule</code> which requires <code>DataComponent</code> to be also scoped.</p>
  
  <p>I've tried to avoid component dependencies by not creating <code>DataComponent</code> and <code>DomainComponent</code> and instead having <code>AppComponent</code> referencing <code>DataModule</code> and <code>DomainModule</code> like below.</p>
  
  <pre><code>@PerApp
  @Component(modules = [DataModule::class, DomainModule::class])
  AppComponent {
     fun tokenRepository(): TokenRepository
     fun jobRepository(): JobRepository
     fun somethingSingleton(): Something
  }
  </code></pre>
  
  <p>However that does not work unless Presentation module declares (gradle) dependencies for data-related libraries like database or caching library which are used to implement the repository. I feel that would ruin the idea of modulization since those dependencies should not be  a concern of the Presentation layer.</p>
  
  <p>I was wondering if any one had the same issue before and how did you resolve it?</p>
  
  <p>Thanks</p>