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.

6 thoughts on “Analyzing jar dependencies

  1. 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.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s