Reputation: 10480
In my application I'm using an external library (Batik 1.7) that is made up of several modules. The modules have multiple cyclic dependencies between themselves. This doesn't influence the build, but some tools (e.g. the M2Eclipse Dependency Graph, or the Dependencies report) will not work anymore.
Is there a good way to diagnose what cycles are there, and an easy way to get rid of them?
Update: The problem is with the POMs, as e.g. batik-bridge
is dependent on batik-gvt
, which is in turn depend upon batik-bridge
.
I think I can solve this by excluding some of the dependencies manually, but I'm not sure what to exclude. What I'd like to have is a clear overview of the cycles in the graph.
Upvotes: 8
Views: 17665
Reputation: 570615
I'm not sure if this is maven related (you can't have cyclic dependencies between modules with maven) but maybe I didn't get something. That said, you can use JDepend to analyze a piece of code and find cyclic dependencies (see Interpreting Dependency Cycles). If you prefer to use JDepend from Eclipse, there is the JDepend4Eclipse plugin.
Check out Batik from its subversion repository, run JDepend on its sources and see if you find something (I guess you will). But, to be honest, that was the easy part. Getting rid of cyclic dependencies is another story and might not be that easy. This might involve tasks like moving classes from one package to another, repackaging modules, understanding how Batik's build work (note that its Ant build script has 2220 lines), etc. In other words, this will require some hard work on a library that you initially just want to use (and unless you contribute these changes, you might have to apply them again with a later release). My advice: think about it twice before starting digging in that direction.
Just for your information, there is also a jdepend-maven-plugin which is only useful if you want to run JDepend on your project (i.e. your code) which is not your request.
Upvotes: 4
Reputation: 9415
Try using UCDetector it helps find dependencies cycles in class level while developing. Another useful tool is Tattletale.
It provide you with reports that can help you
I intentionally skiped maven solutions to not double other responses.
Upvotes: 2
Reputation: 32717
Try running this from the command line in the root of your topmost project:
mvn dependency:tree
Upvotes: 6