Guys, in multimodule setup & Dagger, if my App...
# gradle
u
Guys, in multimodule setup & Dagger, if my AppComponent is created in :app module (and it includes all modules from all modules that wanna be app scoped) so lets say in :core I have NetModule which creates okhttp & retrofit & moshi (edited) now I need to include okhttp and retrofit in :app build.gradle, (obvlously you can see Id have to do that for all such dependencies) which is kind of silly because :app build gradle will be then replicating union of every 3rd party dependency so is
api project(:core)
the solution here? Id like to avoid that or, rather, should I remove `@Provides`˛from
fun okhttp()
,
fun retrofit()
methods and have only my final
ApiClient
be
@Provides
? which however then muddies up the params of the dependency which are before more explicit like:
@Singleton @Provides fun apiClient(api: Api): ApiClient {
(edited) to
Copy code
@Singleton @Provides fun apiClient(context: Context): ApiClient {
        val okHttpClient = okHttpClient(context)
        val moshi = moshi()
        val retrofit = retrofit(okHttpClient, moshi)
        val api = api(retrofit)
        return ApiClient(api)
    }
e
api
configuration is what you need but not in your :app module. You’ll need it for the dependencies in question in your :core module. For example your :core build script will look like
Copy code
implementation project(:dependency-not-exposed-to-app)
api "okhttp"
api "retrofit"
:app can then consume :core as an implementation dependency
Copy code
implementation project(:core)