Enhance your javadoc with ULMGraph
Posted by survivant on December 26, 2009 at 6:38 PM EST
We can't live without Javadoc, but even if it useful, it's not complete. One missing thing is UML within the Javadoc.To add UML to your Javadoc, is quite simple. You need to add Graphviz into your maven build.
First you need to download and install Graphviz. Go there Graphviz
After that you should add the variable GRAPHVIZ_HOME (that point to the installation folder) into your system.
The last step is to add the plugin into your pom.
Add the lines in bold.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.6.1</version>
<configuration>
<links>
<link>http://java.sun.com/javase/6/docs/api/</link>
</links>
<detectOfflineLinks />
<doclet>org.umlgraph.doclet.UmlGraphDoc</doclet>
<!--
use this line or use the variable GRAPHVIZ_HOME
<docletPath>/path/to/UmlGraph.jar</docletPath>
-->
<docletArtifact>
<groupId>org.umlgraph</groupId>
<artifactId>doclet</artifactId>
<version>5.1</version>
</docletArtifact>
<additionalparam>-operations</additionalparam>
<additionalparam>-qualify</additionalparam>
<additionalparam>-types</additionalparam>
<additionalparam>-visibility</additionalparam>
<additionalparam>-collpackages</additionalparam>
<show>private</show>
</configuration>
</plugin>
With that you will have nice UML into your javadoc. I hope that help.Related Topics >>
Blog Links >>
- Login or register to post comments
- Printer-friendly version
- survivant's blog
- 2697 reads






Comments
An alternative without installing Graphviz locally
by felipegaucho - 2009-12-27 01:59
<plugin> <artifactId>maven-javadoc-plugin</artifactId> <configuration> <show>package</show> <version>true</version> <javadocVersion>${source.version}</javadocVersion> <links> <link>http://java.sun.com/javase/6/docs/api/</link> <link>http://java.sun.com/products/servlet/2.5/docs/servlet-2_5-mr2/</link> <link>http://joda-time.sourceforge.net/api-release/</link> <link>http://findbugs.sourceforge.net/api/</link> <link>http://tomcat.apache.org/tomcat-6.0-doc/api/</link> <link>http://jetty.mortbay.org/jetty/jetty-6/apidocs/</link> <link>http://download.eclipse.org/jetty/stable-7/apidocs/</link> <link>https://grizzly.dev.java.net/nonav/apidocs/</link> </links> <source>1.6</source> <code>javadoc:aggregate</code> <code>javadoc:test-aggregate</code> <doclet>gr.spinellis.umlgraph.doclet.UmlGraphDoc</doclet> <docletArtifact> <groupId>gr.spinellis</groupId> <artifactId>UmlGraph</artifactId> <version>4.6</version> </docletArtifact> <additionalparam> -inferrel -inferdep -quiet -hide java.* -collpackages java.util.* -qualify -postfixpackage -nodefontsize 9 -nodefontpackagesize 7 </additionalparam> </configuration> </plugin>It will use Graphviz, but it will download it from the web instead of forcing the local installation.. :)
thanks.
by survivant - 2009-12-30 09:21
thanks.
I tried it before but it didn't work for unknown reason. I'll switch to your way. I prefer that.
How to use Graphviz on non-Maven projects ?
by zesharp - 2010-01-05 06:56
Hi I'd like to have UML on my Javadocs, but had no plans to use Maven. Any ideas ?Never try and didn't look for
by survivant - 2010-01-06 17:14
Never try and didn't look for that. I know there are plugin to ant to launch maven task. Maybe you can use that.
Fantastic!
by aberrant - 2009-12-28 13:53
This immediately went onto my project. Thanks for the tip, both of you.