Graphing your jar dependencies

As i mentioned in an earlier post, we are using ivy to manage jar dependencies.

But Ivy not only manages your jar dependencies, it can also generate documentation, and even graphs displaying the library dependencies of your projects. I generated the following graph using the ivy-report ant task:

ivy-graph

You can generate this graph using ivy in an Ant build file. Here’s the relevant part of the build file:

  <taskdef name="ivy-retrieve" classname="fr.jayasoft.ivy.ant.IvyRetrieve"
	       loaderref="class.path.loaded" classpathref="class.path"/>
  <taskdef name="ivy-report" classname="fr.jayasoft.ivy.ant.IvyReport"
	       loaderref="class.path.loaded" classpathref="class.path"/>
  <!--
	===========================================================================
	== resolve dependencies
	===========================================================================
	-->
  <target name="resolve.dependencies"
	      description="retrieve dependencies with ivy" depends="init">
	<ivy-retrieve pattern="${ivy.lib.dir}/[artifact].[ext]"/>
  </target>
  <!--
	===========================================================================
	== ivy graph
	===========================================================================
	-->
  <target name="ivy.graph" description="generate jar dependency graph"
	      depends="resolve.dependencies">
	<ivy-report todir="${doc.dir}" graph="true"/>
  </target>

The task generates a graphml file. I used the yEd Graph Editor to layout the graph. yEd has pretty powerfull layout algorithms, so you don’t have to use the layout used for the image above. I think for this image i used smart organic layout, which is good if you want to put as much as possible on 1 page. A hierarchical layout is a lot easier to read though.

blog comments powered by Disqus