-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Add Anvil #1112
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Anvil #1112
Conversation
71f21be to
18f70d9
Compare
| @Module | ||
| @ContributesTo( | ||
| scope = AppObjectGraph::class, | ||
| replaces = [AppConfigurationDownloaderModule::class] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is how we replace dagger modules for testing with Anvil. No more TestComponent needed
| @MergeComponent( | ||
| scope = AppObjectGraph::class, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@MergeComponent is the anvil-equivalent to dagger @Component. This annotation is what anvil uses to generate the dagger components under the hood.
The scope is not be confused to eg. ActivityScope or Singleton scope-annotations. It simply is a marker class that identifies the dagger component, so that we can later provide modules/dependencies without needing to get access to the dagger component type
| // accessor to Retrofit instance for test only only for test | ||
| @Named("api") | ||
| fun retrofit(): Retrofit |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should find a better way to do this. This is needed by the ATB e2e tests and it was done in the same manner in the now removed TestComponent.
I will think about this and prob tackle it in a different PR
| } | ||
| dependencies { | ||
| classpath 'com.android.tools.build:gradle:4.1.0' | ||
| classpath 'com.android.tools.build:gradle:4.1.1' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I took the opportunity to bump a patch version here
18f70d9 to
92a984d
Compare
92a984d to
200ca5d
Compare
marcosholgado
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good job @aitorvs! 👏
- Made sure we replaced everything within the
AndroidBindingModule. - Tested updating the app, onboarding, bookmarks, fire button, fireproof, location dialog, pixels, tabs, find in page, privacy dashboard, grade animation, broken sites, icon change and notifications.
Task/Issue URL: https://app.asana.com/0/414730916066338/1199916263225064/f
Tech Design URL:
CC:
Description:
We've been using Dagger Android for a while and it has been good help. We've also seen some drawbacks moving forward
TestComponent, customTestRunnerand a customTestApplicationThis PR:
:dithat is home to the Dagger components marker (scope) annotationscom.duckduckgo.app.di.componentAndroidBindingModule.ktthat used the dagger-android annotation processor (DAAP)@Componentand@SubComponentwith@MergeComponentand@MergeSubComponentcorrespondingly and so we can't do that for the DAAP-generated code.file templatein AS (I did with a file template)Note:
Steps to test this PR:
AndroidBindingModule.kthas now a dedicated file in the packagecom.duckduckgo.app.di.componentBrowserActivity->BrowserActivityComponent.ktInternal references:
Software Engineering Expectations
Technical Design Template