Software Secret Weapons™

 
Maven POM dependencies in GraphML
by Pavel Simakov on 2009-05-01 01:51:55 under Code Linguine, Linguine Maps, Meta-Modeling, Text Mining, view comments
Bookmark and Share
 

The Problem

I have to investigate and get familiar with a large Java framework. It consists of many different modules glued together with Maven. The Maven POM files are everywhere and it is difficult to read them. Are there any tools that can help me learn the content of this large Maven repository?

Yes! The Dependency Analyzer is a great tool by Dror Bereznitsky just for this purpose. The tool walks the Maven dependencies for your project, pretty graphs come out at the other end. For example: here is the Apache Ant 1.7.1 POM dependency graph:

What is missing is the ability to export the graph and I need the data exported for further analysis. In this post I will show you how to patch Dependency Analyzer to add GraphML export.

The Solution

The internal design of Dependency Analyzer 1.1-rc1 was very clean. The Dror Bereznitsky and a team did a great job of putting together a text book quality Swing application.

It was necessary to patch only two files: org.jfrog.maven.viewer.common.jung.JungHelper and org.jfrog.maven.viewer.ui.command.SaveAsCommand. I have added a new file format "graphml" to the SaveAsCommand and hooked up the GraphML generation to the JungHelper. To see it working, open the desired POM file into the Dependency Analyzer. Go to File | Save As menu and choose a file name. Press Enter. Here is the ant-1.7.1.graphml produced.

The GraphML is very convenient format for exporting graphs. My favorite tool for viewing and laying out the graphs in GraphML is yEd. Simply open the ant-1.7.1.graphml file above using yEd. Go to Layout | Hierarchical | Classic and press Enter. Here is the layout:

The Download

You can download the source for the patch described above. I also have a new distribution of Dependency Analyzer with the above changes dependency-analyzer-1.1-rc1.zip.

The Final Word

Maven kicks butt. Compared to Ant, it has much more metadata about the artifacts and their source, build, test and deploy dependencies. But dude... Do we really need 1,000,000 lines of code just to run Ant? Scarry...

Comment (1)

  • Comment by 4gb carte memoire — December 14, 2009 @ 7:32 am

    As a Google Summer of Code participant, this summer I’ll be working on a dependency graphing plugin, with Carlos Sanchez as mentor. See http://docs.codehaus.org/display/MAVEN/Dependency+Graphing for background. This page describes the necessary design to support interactive dependency graphs. This is on a separate page from the main Maven Diagram Maker page for now because it remains to be determined whether the UI should be merged, or if there is even a common core of classes to use.


Leave a comment


  Copyright © 2004-2012 by Pavel Simakov
any conclusions, recommendations, ideas, thoughts or the source code presented on this site are my own and do not reflect a official opinion of my current or past employers, partners or clients