github.com/google/dagger/issues/1225

я сложная многоуровневая архитектура в моем проекте Android.

В настоящее время я хочу использовать следующую структуру компонентов и модулей DI:

[Data Layer]
    @DataScope //scope is used for caching (Singleton) some Data Layer entities for whole application
    - DataComponent //exposes just interfaces which should be used on the BL Layer
        //Modules exposes entities for internal (Data Layer) injections and entities which exposed by DataComponent for BL Layer
        * DataModule1
        * DataModule2
        * DataModule3

[Business Logic Layer] (also has component dependency on DataComponent)
    @BlScope //scope is used for caching (Singleton) some BL Layer entities for whole application
    - BlComponent //exposes just interfaces which should be used on the Service Layer & Presentation Layer
        //Modules exposes entities for internal (BL Layer) injections and entities which exposed by BLComponent for the Service Layer & Presentation Layer
        * BlModule1
        * BlModule2

[Service Layer] (also has component dependency on BlComponent) - this layer has Android specific entities (Android Service, ContentProvider) not related to the Presentation Layer
    @ServiceScope //scope is used for caching (Singleton) some Service Layer entities for whole application
    - ServiceComponent //exposes just interfaces which should be used on the Presentation Layer
        * ServiceModule //Module exposes entities for internal (Service Layer) injections and entities which exposed by ServiceComponent for the Presentation Layer

[Presentation Layer] (also has component dependency on: ServiceComponent, BlComponent)
    @PresentationScope //scope is used for caching (Singleton) some Presentation Layer entities for whole application
    - PresentationComponent //exposes just interfaces which should be used on the current layer
        * PresentationModule //Module exposes entities injections on the current layer

ServiceComponent & BlComponent не предоставляют подобные интерфейсы.

Для построения основного графа я использую следующий код:

DataComponent dataComponent = DaggerDataComponent.builder().<addModules>.build();
BlComponent dataComponent = DaggerBlComponent.builder().<addModules>.dataComponent(dataComponent).build();
ServiceComponent serviceComponent = DaggerServiceComponent.builder().<addModule>.blComponent(blComponent).build();
PresentationComponent presentationComponent = DaggerPresentationComponent.builder().<addModule>.blComponent(blComponent).serviceComponent(serviceComponent).build();

В PresentationLayer я использую только «presentationComponent», чтобы обеспечить необходимые зависимости от ServiceComponent / Layer и BLComponent / Layer.

В настоящее время приведенный выше сценарий не работает, потому что PresentationComponent зависит от 2 компонентов области действия с ошибкой

«... зависит от более чем одного компонента области действия: ...»

Хотя это позволяет использовать один компонент с областью действия со многими компонентами без области действия. Эта архитектура направлена ​​на ограничение использования сущностей внутреннего уровня на верхних уровнях и в то же время на проведение независимых тестов (юнитов и приборов) на каждом слое / модуле.

Кто-нибудь может помочь мне понять, это ошибка или желаемое поведение процессора Dagger? (и почему?) Проблема репозитория Dagger2:https://github.com/google/dagger/issues/747#issuecomment-303526785

Ответы на вопрос(1)

Ваш ответ на вопрос