Class diagram generation from Java source
Maven plugin details
UMLGraph can be easily integrated with existing maven based application. Below is the maven plugin details which needs to be configured:
<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-javadoc-plugin</artifactId> <configuration> <doclet>org.umlgraph.doclet.UmlGraphDoc</doclet> <docletArtifact> <groupId>org.umlgraph</groupId> <artifactId>doclet</artifactId> <version>5.1</version> </docletArtifact> <additionalparam>-horizontal -attributes -enumconstants -enumerations -operations -types -visibility -inferrel -inferdep -hide java.* -inferrel -collpackages java.util.*</additionalparam> <show>public</show> </configuration> </plugin>
UMLGraph depends upon Graphviz which must be already installed on the machine. Also in the above maven setting if you configure ‘GRAPHVIZ_HOME’ environment variable you need not specify the docletpath in plugin details.
Steps to configure UMLGraph
- Download and install Graphviz
- Set GRAPHVIZ_HOME environment variable.
- Add the above plugin details in your POM.xml, configure additionalparams per your need.
- execute ‘mvn javadoc:javadoc’.
Sample
Below is the sample generated using above configuration over our Pizza entity pizza_class_diagram.png
More configuration
You can configure this diagram per your needs. Please refer UMLGraph class diagram options for more configuration.
Reference: Class diagram generation from Java source from our JCG partner Abhishek Jain at the NS.Infra blog.