I have a bit of a funny problem and instead of looking for a solution to it, I'm looking for solutions.
Project Alice has a pom.xml. In it the pom says she gets packaged as a jar and although she is a strong woman, she is dependent on Bob. Project Bob, being a complementarian, says he depends on Alice. Ergo a circular dependency.
Of course, running mvn compile
on Alice says "Alice is missing Bob". And Bob, that true romantic, if you try and compile him, he misses Alice too.
Since neither will comply without the other present, I'm looking for ways to resolve this.
There is only two ways I know how to resolve this:
Besides the fact that I don't want to promote incest, would making a parent pom and making Alice and Bob siblings solve this?
Any other solutions?
There are a couple of options to get rid of circular dependencies. For a longer chain, A -> B -> C -> D -> A , if one of the references is removed (for instance, the D -> A reference), the cyclic reference pattern is broken, as well. For simpler patterns, such as A -> B -> A , refactoring may be necessary.
Maven does not allow cyclic dependencies between projects, because otherwise it is not clear which project to build first. So you need to get rid of this cycle. One solution is the one you already mentioned, to create another project.
When you see the circular dependency detected error displayed in your Google spreadsheet, this means that your formula is referring to a range that contains the formula itself, or in other words when the formula input, is dependent on the output.
Figure out what it is that Alice and Bob desperately need from each other, and introduce that - let's call it Charlie - as its own separate POM. Then, have Alice and Bob depend on Charlie.
The big thing to note here is that circular dependencies arise often due to certain modules encompassing more than it needs to. Given that Alice needs Bob and Bob needs Alice, there is something that could be split off from within those two modules and introduced as a third one.
This is probably not the most attractive solution, but it's the cleanest. You then introduce more modularity into your system, and some more opportunities for module refactoring.
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