In a multi-module project, should a kotlin module ...
# coroutines
o
In a multi-module project, should a kotlin module that exposes Flow as its public api, specify its coroutines dependency as
api
instead of
implementation
? Also if so, does this also mean for target dependencies (e.g. commonMain:
api(coroutines-core-common)
and jvmMain:
api(coroutines-core)
)
o
yes to the first question, I don't know if it matters for the second
t
Since you're exposing the
Flow
type to other modules, it is wise to also share dependency on coroutines-core, otherwise consumer modules won't be able to resolve
Flow
(unless they also specify coroutines-core as dependency) I haven't tried MPP yet, but I think it also applies. Just declare the correct dependency as
api
for the corresponding platform:
commonMain
-> coroutines-core-common
jvmMain
-> coroutines-core
jsMain
-> coroutines-core-js etc.
o
Allright so api on all targets including common. The thing is, I was doing that, but getting errors that there was some conflicting dependencies or that it couldnt access flow because of module classpath. Replacing the api cascadings with all modules implementing the coroutines dependencies on their own fixed it.