Enhance your javadoc with ULMGraph

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.

A simplier way is to add that instead in the pom.xml


<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>
This entry was posted in Uncategorized by . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>