JuulLabs / stropping

Stropping performs reflection on Dagger to make instrumented testing easier.
Apache License 2.0
4 stars 1 forks source link

Support for Dagger's new Hilt architecture #17

Open cedrickcooke opened 4 years ago

cedrickcooke commented 4 years ago

This is gonna be a big one, but it's also too early to actually start on it. Just tracking for now.

cedrickcooke commented 4 years ago

Proposed Solutions

Reverse Relationship of Module Dependencies

After some discussion, we think the approach here is to add an annotation processor to look at @InstallIn classes and build the list of included modules that way. The goal is providing a generated function which knows which classes to include in the dependency graph w/o having to reflect on the @Component and @Module annotations. Something to the effect of:

// before
Replacements.of<ApplicationComponent> { }

// after
Replacements.ofApplicationComponent { }

This will be a breaking change, but with pretty easy transition.

Entry Point Changes

Before, we did @ContributesAndroidInjector in a module, now it's @AndroidEntryPoint on the class. This shouldn't require any changes -- Stropping never used the @ContributesAndroidInjector and has always just used reflection for the @Inject fields.

Scoping

We might need to do a lot of special casing for this, but ideally we can simply recurse down the list of components as necessary, just adding bindings at each step.

The relationship is well documented here: https://dagger.dev/hilt/components#component-hierarchy