https://kotlinlang.org logo
#kapt
Title
# kapt
a

agrosner

08/22/2018, 3:49 PM
Dagger works fine with multiple modules in fact you can use this example. My company is building a completely open source app for the art institute of Chicago: github.com/art-institute-of-chicago/aic-mobile-android I do most of the code reviews and we welcome all contributions once development slows down
c

cristiangm

08/22/2018, 4:02 PM
All your modules are using KAPT
a

agrosner

08/22/2018, 4:09 PM
Yes most of them
c

cristiangm

08/22/2018, 4:13 PM
I thought the idea was to leave a few modules with KAPT and have most of them clean of annotation processors
a

agrosner

08/22/2018, 4:25 PM
The ones that have dagger modules yeah they have kapt. Not all of them do
It's possible to go even more granular on modules
j

jw

08/22/2018, 7:37 PM
When you have granular modules their use of kapt becomes mostly irrelevant because they can be individually cached to avoid compilation altogether and when they do require it they can be built in parallel with others
g

gildor

08/23/2018, 1:46 AM
Dagger works, but if you use dagger-android or Subcomponents each change of this subscomponent cause your module with app component recompilation
j

jw

08/23/2018, 1:46 AM
dagger-android is a huge win because it means you can move individual activities and fragments to their own modules
a

agrosner

08/23/2018, 1:47 AM
shouldnt be so bad if your app module component is a shell that just ties everything together
☝️ 1
j

jw

08/23/2018, 1:48 AM
you almost never want dagger-android if your activities and fragments are in the same Gradle module as their enclosing application/activity. you're just adding abstraction for no purpose.
☝️ 1
g

gildor

08/23/2018, 1:51 AM
Yes, dagger-android easily allows you to extract fragments/activities, but in terms of incremental compilation Component works better than Subcomponent, this is especially the thing if you have a lot of subcomponents, so change of any of them cause AppComponent recompilation.
a

agrosner

08/23/2018, 1:51 AM
and since its runtime checking for those bindings, you can run into runtime exceptions if you forget to include the
ContributesAndroidInjector
in your module
j

jw

08/23/2018, 1:51 AM
but it doesn't really matter because your app module will be mostly empty and just tie together the other modules which can all run in parallel
so Dagger gets a few seconds slower when your overall build gets multiple tens of seconds faster
g

gildor

08/23/2018, 1:52 AM
shouldnt be so bad if your app module component is a shell that just ties everything together
It’s true, but if you have legacy application where most of code still in App module, don’t expect immediate build improvement
a

agrosner

08/23/2018, 1:52 AM
yeah! I get like sub 20 second builds in our AIC project when changing a feature leaf even though it depends on app
j

jw

08/23/2018, 1:57 AM
but if you have a legacy app with most of the code in the app module you shouldn't be using dagger-android anyway. and modularization is what you should be focusing on. incremental <insert anything> isn't going to be a big win ever in that case.
a

agrosner

08/23/2018, 1:57 AM
yeah, modularization can be interesting, but it does uncover a lot of tangled dependencies you might have and youll start seeing some great improvements
6 Views