I have an Android application with the following setup:
2 gradle modules: app and feature (just started modularising and this is the first feature module of many)
In the feature module FeatureModule which is a Dagger @Module providing dependencies for the feature.
In the app module AppComponent handling all the dependencies, having a reference to the FeatureModule (@Component(modules = [...,FeatureModule::class]))
This is working fine. The problem is that I need these lines in both of the module's build.gradles:
apply plugin: 'kotlin-kapt'
....
implementation 'com.google.dagger:dagger-android-support:2.22.1'
implementation 'com.google.dagger:dagger:2.22.1'
kapt 'com.google.dagger:dagger-compiler:2.22.1'
kapt 'com.google.dagger:dagger-android-processor:2.22.1'
As far as I know, adding kapt to all the feature modules slows the build down significantly (I might be wrong on this tho).
So I only want to have these lines in the feature module's build.gradle:
implementation 'com.google.dagger:dagger-android-support:2.22.1'
implementation 'com.google.dagger:dagger:2.22.1'
This might be a different topic but I'm gonna ask it anyways. Do you think I should create a separate @Component for the feature module (and the other feature modules to come) or is it enough to have a separate Dagger @Module for them?
Actually I tried to create a @Component, but I only found examples about it for the @Component.Builder setup and I'm using the new @Component.Factory one.
The only reason why I'm considering the component is so that I could give a different @Scope for the feature, but I don't think I want to do that now. Do you know about any other reason for me to do that?
Thanks in advance!
It doesn't seem possible but I was able to do the following workaround.
You should replace implementation in the core module with api. So your code will look like this,
core build.gradle:
apply plugin: 'kotlin-kapt'
....
api 'com.google.dagger:dagger:2.22.1'
kapt 'com.google.dagger:dagger-compiler:2.22.1'
feature build.gradle:
apply plugin: 'kotlin-kapt'
....
implementation project(':core')
kapt 'com.google.dagger:dagger-compiler:2.22.1'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With