Is it possible to have cyclic dependence between modules of a multi-module project?
Here is an example:
lazy val client = (project in file("client"))
.dependsOn(service)
.settings(...)
lazy val service = (project in file("service"))
.dependsOn(client)
.settings(...)
Im getting an error recursive value x needs type
which I think is due to this recursive definition, but not completely sure (there might be some other weird phenomenon causing this).
Why you ever need this? No build system provide support for cyclic dependencies, because its impossible to maintain correct build order in such case. If your module service depends on part of client, then you should move it out to a separate module (usually we call it common):
lazy val common = (project in file("common"))
lazy val client = (project in file("client"))
.dependsOn(service, common)
.settings(...)
lazy val service = (project in file("service"))
.dependsOn(common)
.settings(...)
Also, it's considered as a good practice to have separate sub-modules for service API and service implementation (service-api and service-impl). This way allows to decouple client from service implementation details
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With