dagger-reflect
dagger-reflect copied to clipboard
Reflect compiler not generating default builder class.
By default, dagger-compiler generates a default Builder
class.
With setup such as this:
interface Host {
fun myDependency(): MyDependency
}
@Component(dependencies = [Host::class])
interface MyFeatureComponent {
fun feature(): MyFeature
}
there will be a generated method
DaggerMyFeatureComponent.builder().dependencies(myDependencies).build()
We have a bunch of ignored functional tests for the same reason:
// TODO reflect-compiler bug! Not generating builder method.
exclude 'dagger/functional/builder/BuilderTest.java'
exclude 'dagger/functional/cycle/DoubleCheckCycleTest.java'
exclude 'dagger/functional/membersinject/MembersInjectionOrderingTest.java'
exclude 'dagger/functional/nullables/NullabilityTest.java'
exclude 'dagger/functional/MultibindingTest.java'
exclude 'dagger/functional/NonComponentDependencyTest.java'
Is there any workaround that can be used in the meantime for this? Can I provide the dependencies some other way?
My setup is roughly like this:
@Component(modules = [ FooModule::class ])
interface MyComponent { ... }
@Module
class FooModule(private val myInjectedActivity: BaseInjectedActivity) { ... }
abstract class BaseInjectedActivty {
override fun onCreate(...) {
val myComponent = DaggerMyComponent.builder().fooModule(FooModule(this)).build()
}
We declared @Component.Factory interface to workaround.
On Wed, Aug 14, 2019, 4:59 PM Rohan Dhruva [email protected] wrote:
Is there any workaround that can be used in the meantime for this? Can I provide the dependencies some other way?
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/JakeWharton/dagger-reflect/issues/145?email_source=notifications&email_token=AAWYO27KTCPMSZOGEXMJXDLQESL5FA5CNFSM4IEUY4DKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD4KOFXA#issuecomment-521462492, or mute the thread https://github.com/notifications/unsubscribe-auth/AAWYO23JZ7S324YHMR5FYOLQESL5FANCNFSM4IEUY4DA .
Hi @Laimiux , would you share how you used @Component.Factory
to work it around?
Hi @Laimiux , would you share how you used
@Component.Factory
to work it around?
You have to explicitly declare a factory
@Component(dependencies = [Host::class])
interface MyFeatureComponent {
@Component.Factory
interface Factory {
fun create(host: Host): MyFeatureComponent
}
fun feature(): MyFeature
}
Thank you!