I discovered this cool utility, jaranalyzer. It analyzes a bunch of jars and gives you either an xml or a dot file, that you can process with Graphviz.
Below is the graph generated for spring 2.0-m2 after removing transitive edges
And this is for hibernate 3.1.2 + annotations 3.1beta8 without the transitive edges too
I think this makes more clear why the need of dependency management (aka avoid the jarmageddon 😉 ) I hope people check this tool before making upload bundles.
Some interesting facts:
- circular dependencies, like ehcache and hibernate2, a good chicken and egg problem. Also jaxen-dom4j and jaxen-jdom
- spring modules for database management (jdo, jpa, hibernate2, hibernate3) depend on spring portlet module (curious, isn’t it?).
- spring support depend on different, unrelated, stuff like quartz, BEA’s commonj_twm, ehcache,… I’d say chances are almost 0% that you use two of them at the same time
- several jars, like commons-logging, depend on clover. This is clearly an error caused because clover bundles classes from log4j and other projects, beware of the evil bundling!!! follow the DRY principle also in your jars.
I wasn’t able to find a good alternative to Graphviz implemented in pure Java, so you need to have it installed to generate the graphs from the dot files.
JarJar was doing this kind of stuff way before this tool… http://sixlegs.com/blog/java/depfind.html
Thanks for the info. is worth mention that jarjar is GPL while jaranalyzer is BSD
That looks very interesting. I am using tools like jdepend or the eclipse metrics plugin which has problems showing the graphic for large projects (I have to work with a code base of over 2000 classes which end up in one big clowd in the metrics graphic). I am curious how this tool will handle it.
i also miss graphviz in java but some days ago i discovered http://prefuse.sourceforge.net/ and http://touchgraph.sourceforge.net/ that seems to fits in the same category
Would be nice to have a Maven plugin that could do this on your project… I assume there are none, right?
Juan: prefuse gallery is amazing!
About this in maven, more info is at http://docs.codehaus.org/display/MAVEN/Dependency+Graphing