Sunday, May 3, 2009

Using UmlGraph with Maven

I have used UmlGraph to generate class diagrams inside javadocs in most of the projects that I'm involved to.
Latest version available in Central Maven repository is 4.6. This is a pretty old version of UmlGraph that for me throws NullPointerException every time I'm using generics in code.
Solution that I found to be able to generate class diagrams for projects was to migrate to a new version of UmlGraph, version 5.2. UmlGraph vesion 5.2 is the latest available at the moment of writing this blog entry.
However, this latest vesion is not availble in Maven Central repository. The solution is to install it in local repository or organization remote repository.
To install locally, here is the command line:

mvn install:install-file -Dpackaging=jar -DartifactId=UmlGraph -Dversion=5.2 -Dfile=/home/{user}/opt/UmlGraph-5.2.jar -DgroupId=gr.spinellis -DgeneratePom=true


Command assume that you have downloaded the jar from UmlGraph site to /home/{user}/opt folder.

Also UmlGraph code has been re-organized and the doclet is located in org.umlgraph.doclet package. To use it in your project you have to specify the doclet as part of javadoc maven plug-in:


<plug-in>
<artifactid>maven-javadoc-plugin</artifactid>
<configuration>
<source>1.5</source>
<aggregate>true</aggregate>
<doclet>org.umlgraph.doclet.UmlGraphDoc</doclet>
<docletartifact>
<groupid>gr.spinellis</groupid>
<artifactid>UmlGraph</artifactid>
<version>5.2</version>
</docletartifact>
<additionalparam>
-all -inferrel -inferdep -quiet -hide java.*
-collpackages java.util.* -qualify
-postfixpackage -nodefontsize 9
-nodefontpackagesize 7 -outputencoding utf8
</additionalparam>
</configuration>
</plug-in>