diff --git a/appnav/src/main/kotlin/io/element/android/appnav/LoggedInAppScopeFlowNode.kt b/appnav/src/main/kotlin/io/element/android/appnav/LoggedInAppScopeFlowNode.kt index ee7440cedb..ef3d4b27b9 100644 --- a/appnav/src/main/kotlin/io/element/android/appnav/LoggedInAppScopeFlowNode.kt +++ b/appnav/src/main/kotlin/io/element/android/appnav/LoggedInAppScopeFlowNode.kt @@ -36,7 +36,7 @@ import io.element.android.libraries.matrix.ui.media.ImageLoaderHolder import kotlinx.parcelize.Parcelize /** - * `LoggedInAppScopeFlowNode` is a Node responsible to set up the Dagger + * `LoggedInAppScopeFlowNode` is a Node responsible to set up the Session graph. * [io.element.android.libraries.di.SessionScope]. It has only one child: [LoggedInFlowNode]. * This allow to inject objects with SessionScope in the constructor of [LoggedInFlowNode]. */ diff --git a/docs/_developer_onboarding.md b/docs/_developer_onboarding.md index 65e8bafbe0..6fb5229eeb 100644 --- a/docs/_developer_onboarding.md +++ b/docs/_developer_onboarding.md @@ -260,7 +260,7 @@ Here are the main points: 2. Views are compose first 3. Presenters are also compose first, and have a single `present(): State` method. It's using the power of compose-runtime/compiler. 4. The point of connection between a `View` and a `Presenter` is a `Node`. -5. A `Node` is also responsible for managing Dagger components if any. +5. A `Node` is also responsible for managing DI graph if any, see for instance `LoggedInAppScopeFlowNode`. 6. A `ParentNode` has some children `Node` and only know about them. 7. This is a single activity full compose application. The `MainActivity` is responsible for holding and configuring the `RootNode`. 8. There is no more needs for Android Architecture Component ViewModel as configuration change should be handled by Composable if needed. @@ -422,7 +422,7 @@ Rageshake can be very useful to get logs from a release version of the applicati - When this is possible, prefer using `sealed interface` instead of `sealed class`; - When writing temporary code, using the string "DO NOT COMMIT" in a comment can help to avoid committing things by mistake. If committed and pushed, the CI will detect this String and will warn the user about it. (TODO Not supported yet!) -- Very occasionally the gradle cache misbehaves and causes problems with Dagger. Try building with `--no-build-cache` if Dagger isn't behaving how you expect. +- Very occasionally the gradle cache misbehaves and causes problems with code generation. Adding `--no-build-cache` to the `gradlew` command line can help to fix compilation issue. ## Happy coding! diff --git a/features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/timeline/di/TimelineItemEventContentKey.kt b/features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/timeline/di/TimelineItemEventContentKey.kt index 74c184dde4..e315da06f2 100644 --- a/features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/timeline/di/TimelineItemEventContentKey.kt +++ b/features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/timeline/di/TimelineItemEventContentKey.kt @@ -13,7 +13,7 @@ import kotlin.reflect.KClass /** * Annotation to add a factory of type [TimelineItemPresenterFactory] to a - * Dagger map multi binding keyed with a subclass of [TimelineItemEventContent]. + * dependency injection map multi binding keyed with a subclass of [TimelineItemEventContent]. */ @Retention(AnnotationRetention.RUNTIME) @MapKey diff --git a/features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/timeline/di/TimelineItemPresenterFactories.kt b/features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/timeline/di/TimelineItemPresenterFactories.kt index 994c184114..7df549223e 100644 --- a/features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/timeline/di/TimelineItemPresenterFactories.kt +++ b/features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/timeline/di/TimelineItemPresenterFactories.kt @@ -20,7 +20,7 @@ import io.element.android.libraries.di.RoomScope import kotlin.reflect.KClass /** - * Dagger module that declares the [TimelineItemPresenterFactory] map multi binding. + * Container that declares the [TimelineItemPresenterFactory] map multi binding. * * Its sole purpose is to support the case of an empty map multibinding. */ diff --git a/features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/timeline/di/TimelineItemPresenterFactory.kt b/features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/timeline/di/TimelineItemPresenterFactory.kt index 6954f7f37a..ccb5bec542 100644 --- a/features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/timeline/di/TimelineItemPresenterFactory.kt +++ b/features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/timeline/di/TimelineItemPresenterFactory.kt @@ -13,7 +13,7 @@ import io.element.android.libraries.architecture.Presenter /** * A factory for a [Presenter] associated with a timeline item. * - * Implementations should be annotated with [AssistedFactory] to be created by Dagger. + * Implementations should be annotated with [dev.zacsweers.metro.AssistedFactory] to be created by the dependency injection library. * * @param C The timeline item's [TimelineItemEventContent] subtype. * @param S The [Presenter]'s state class. diff --git a/libraries/architecture/src/main/kotlin/io/element/android/libraries/architecture/Bindings.kt b/libraries/architecture/src/main/kotlin/io/element/android/libraries/architecture/Bindings.kt index 12fa4c8bd9..4188b0a70a 100644 --- a/libraries/architecture/src/main/kotlin/io/element/android/libraries/architecture/Bindings.kt +++ b/libraries/architecture/src/main/kotlin/io/element/android/libraries/architecture/Bindings.kt @@ -12,12 +12,11 @@ import android.content.ContextWrapper import com.bumble.appyx.core.node.Node import io.element.android.libraries.di.DependencyInjectionGraphOwner -inline fun Node.optionalBindings() = optionalBindings(T::class.java) inline fun Node.bindings() = bindings(T::class.java) inline fun Context.bindings() = bindings(T::class.java) fun Context.bindings(klass: Class): T { - // search dagger components in the context hierarchy + // search the components in the dependency injection graph return generateSequence(this) { (it as? ContextWrapper)?.baseContext } .plus(applicationContext) .filterIsInstance() @@ -28,16 +27,13 @@ fun Context.bindings(klass: Class): T { ?: error("Unable to find bindings for ${klass.name}") } -fun Node.optionalBindings(klass: Class): T? { - // search dagger components in node hierarchy +fun Node.bindings(klass: Class): T { + // search the components in the node hierarchy return generateSequence(this, Node::parent) .filterIsInstance() .map { it.graph } .flatMap { it as? Collection<*> ?: listOf(it) } .filterIsInstance(klass) .firstOrNull() -} - -fun Node.bindings(klass: Class): T { - return optionalBindings(klass) ?: error("Unable to find bindings for ${klass.name}") + ?: error("Unable to find bindings for ${klass.name}") } diff --git a/libraries/architecture/src/main/kotlin/io/element/android/libraries/architecture/NodeFactories.kt b/libraries/architecture/src/main/kotlin/io/element/android/libraries/architecture/NodeFactories.kt index 45ea9338a5..4bddbc5541 100644 --- a/libraries/architecture/src/main/kotlin/io/element/android/libraries/architecture/NodeFactories.kt +++ b/libraries/architecture/src/main/kotlin/io/element/android/libraries/architecture/NodeFactories.kt @@ -37,7 +37,7 @@ inline fun NodeFactoriesBindings.createNode( val nodeClass = N::class val nodeFactoryMap = nodeFactories() // Note to developers: If you got the error below, make sure to build again after - // clearing the cache (sometimes several times) to let Dagger generate the NodeFactory. + // clearing the cache (sometimes several times) to let codegen generate the NodeFactory. val nodeFactory = nodeFactoryMap[nodeClass] ?: error("Cannot find NodeFactory for ${nodeClass.java.name}.") @Suppress("UNCHECKED_CAST") diff --git a/libraries/mediaviewer/impl/src/main/kotlin/io/element/android/libraries/mediaviewer/impl/gallery/di/MediaItemEventContentKey.kt b/libraries/mediaviewer/impl/src/main/kotlin/io/element/android/libraries/mediaviewer/impl/gallery/di/MediaItemEventContentKey.kt index 5fda507174..eb04d88787 100644 --- a/libraries/mediaviewer/impl/src/main/kotlin/io/element/android/libraries/mediaviewer/impl/gallery/di/MediaItemEventContentKey.kt +++ b/libraries/mediaviewer/impl/src/main/kotlin/io/element/android/libraries/mediaviewer/impl/gallery/di/MediaItemEventContentKey.kt @@ -13,7 +13,7 @@ import kotlin.reflect.KClass /** * Annotation to add a factory of type [MediaItemPresenterFactory] to a - * Dagger map multi binding keyed with a subclass of [MediaItem.Event]. + * DI map multi binding keyed with a subclass of [MediaItem.Event]. */ @Retention(AnnotationRetention.RUNTIME) @MapKey diff --git a/libraries/mediaviewer/impl/src/main/kotlin/io/element/android/libraries/mediaviewer/impl/gallery/di/MediaItemPresenterFactories.kt b/libraries/mediaviewer/impl/src/main/kotlin/io/element/android/libraries/mediaviewer/impl/gallery/di/MediaItemPresenterFactories.kt index 352b4f0b7c..eaf0f5a49e 100644 --- a/libraries/mediaviewer/impl/src/main/kotlin/io/element/android/libraries/mediaviewer/impl/gallery/di/MediaItemPresenterFactories.kt +++ b/libraries/mediaviewer/impl/src/main/kotlin/io/element/android/libraries/mediaviewer/impl/gallery/di/MediaItemPresenterFactories.kt @@ -20,7 +20,7 @@ import io.element.android.libraries.mediaviewer.impl.model.MediaItem import kotlin.reflect.KClass /** - * Dagger module that declares the [MediaItemPresenterFactory] map multi binding. + * Container that declares the [MediaItemPresenterFactory] map multi binding. * * Its sole purpose is to support the case of an empty map multibinding. */ diff --git a/libraries/mediaviewer/impl/src/main/kotlin/io/element/android/libraries/mediaviewer/impl/gallery/di/MediaItemPresenterFactory.kt b/libraries/mediaviewer/impl/src/main/kotlin/io/element/android/libraries/mediaviewer/impl/gallery/di/MediaItemPresenterFactory.kt index 9730fb4c05..0b3c77eda1 100644 --- a/libraries/mediaviewer/impl/src/main/kotlin/io/element/android/libraries/mediaviewer/impl/gallery/di/MediaItemPresenterFactory.kt +++ b/libraries/mediaviewer/impl/src/main/kotlin/io/element/android/libraries/mediaviewer/impl/gallery/di/MediaItemPresenterFactory.kt @@ -13,7 +13,7 @@ import io.element.android.libraries.mediaviewer.impl.model.MediaItem /** * A factory for a [Presenter] associated with a timeline item. * - * Implementations should be annotated with [AssistedFactory] to be created by Dagger. + * Implementations should be annotated with [dev.zacsweers.metro.AssistedFactory] to be created. * * @param C The timeline item's [MediaItem.Event] subtype. * @param S The [Presenter]'s state class. diff --git a/plugins/src/main/kotlin/extension/KoverExtension.kt b/plugins/src/main/kotlin/extension/KoverExtension.kt index eee2d7cada..33148ca277 100644 --- a/plugins/src/main/kotlin/extension/KoverExtension.kt +++ b/plugins/src/main/kotlin/extension/KoverExtension.kt @@ -67,14 +67,12 @@ fun Project.setupKover() { "*_ModuleKt", "com.airbnb.android.showkase*", "io.element.android.libraries.designsystem.showkase.*", - "io.element.android.x.di.DaggerAppComponent*", "*_Factory", "*_Factory_Impl", "*_Factory$*", "*_Module", "*_Module$*", "*Module_Provides*", - "Dagger*Component*", "*ComposableSingletons$*", "*_AssistedFactory_Impl*", "*BuildConfig",