Resolving or Compiling Circular Dependency in Maven

java, maven

Solution

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.

Problem

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: - Marry them and make them one maven project. - Break their co-dependency 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?

Original source

Related problems