Analyzing jar dependencies

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.