Reputation: 4443
I have an issue in my application design. I have a item viewer application, let's call it V
and want to extend it with an editor project, let's call it E
.
E
depends on many classes of V
, because it provides a graphical preview of the items. So E
there is a Maven dependency E
->V
. Now I want to integrate E
into V
, because users should be able to start the editor out of the viewer. That means I also have a Maven dependency V
->E
which causes a dependency cycle. I tried different scope
values but was not able to break the cycle. How can I achieve this?
The V
project is a very monolithic and not well-structured bunch of code and I don't want to divide it. In the E
project I can do anything I want (in fact it already consists of many small projects).
Upvotes: 0
Views: 62
Reputation: 43728
One way is to split out the API parts of each project (basically the interfaces that are called from the other). This would give you dependencies like this:
v -> Vapi
E -> Vapi
V -> Eapi
E -> Eapi
and there are no cycles.
If you don't want to split V a scheme like this may work:
E -> V
E -> Eapi
V -> Eapi
Upvotes: 1
Reputation: 77177
You need to write your view code to work with an interface instead of a class; this is a best practice in any case. Put the relevant interface
files in module foo-api
, and then have foo-domain
and foo-view
depend on foo-api
.
Upvotes: 1