Blog

06 Jan, 2009

How to auto generate UML class diagrams in JavaDoc with Maven2 and Apiviz

Posted by: admin In: Programming

For some time I’ve been looking for a way to auto generate UML diagrams inside JavaDoc files. The perfect solution would integrate into Maven 2, which is my build system of choice. A few days ago I stumbled across Apiviz, which turned out to be exactly what I’ve been looking for! It provides simple integration with Maven, Ant and Eclipse.

By default it draws implementation of interfaces and inheritance and if you add some tags / annotations to your JavaDoc it will draw composition, aggregation, dependencies and navigable relationships as well. There are some undocumented options as well. I’ve used the Netty source code as a reference as it seems to be the project maintainer of Netty that’s behind ApiWiz (shoot me if I’m wrong).

I’m in progress of uncovering some of the undocumented features. If someone knows something I appreciate a comment below.

Example from the Netty project

Example from the Netty project

Update: After digging through the source code (gotta love open source!) I found the documentation missing from the web page! This documentation shows how to add labels to the edges.

apiviz.uses
<FQCN> [<sourceLabel> <targetLabel> [<edgeLabel>]]
 
apiviz.has
<FQCN> [oneway] [<sourceLabel> <targetLabel> [<edgeLabel>]]
 
apiviz.owns
<FQCN> [<sourceLabel> <targetLabel> [<edgeLabel>]]
 
apiviz.composedOf
<FQCN> [<sourceLabel> <targetLabel> [<edgeLabel>]]

FQCN is short for “Fully Qualified Class Name”.

No Responses to "How to auto generate UML class diagrams in JavaDoc with Maven2 and Apiviz"

Comment Form