-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Resolving Circular Dependencies
Circular dependencies occur when a providing project starts to depend somehow on a consumer of itself.
The simplest circular dependency involves 2 projects that depend on one another. But they can also involve more than 2 projects.
There are several reasons why circular dependencies may arise.
A common case is that 2 separate projects contain tightly knit logic which frequently has to depend on each other. Usually, having granular projects is recommended. However, in this case, it may be more reasonable to collapse such projects into a single project that is free to depend on itself.
Another common case is that the consumer of a project has some extra logic that is desirable from producing libraries. When this extra logic is consumed by a producing project, it creates a circular dependency. The solution to this case is to separate the extra logic in the producing project into a new project that is shared between the projects which desire this logic:
There may be other reasons that have not been described here in this document or are not generalizable.
A consuming project is a project that imports another project.
A providing project is a project that is imported by another project.