We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 5 years ago.
Improve this questionI'm trying to find a tool/framework/plugin that will allow me to draw UML diagrams inside my javadocs comments. I don't need 开发者_如何转开发reverse engineered automated UML pictures (which are effectively provided by UMLGraph and others). I would like to have an ability to create my own custom diagrams. Can you suggest any?
I tried 3 ways of doing this, generating UML Diagrams inside the JavaDocs using maven-javadoc-plugin and doclets:
1) UmlGraphDoc
2) apiviz
3) yworks
And I may say that the best is the option 3, this because it's the only one that does not need to install something in the development pc.
For UmlGraphDoc and apiviz (both doclets) they required to install GraphViz in the PC.
Install it and configure the maven-javadoc-plugin is easy, but since they required a separate application, it turns the UML generation a bit dirty, since if you want to include the uml generation as part of your maven lifecycle, all the other developers will need to install GraphViz (A dependency that I really wanted to avoid).
Anyway, this link has the approach I followed, of using yworks (it really works):
- http://archive.keyboardplaying.org/2012/05/29/javadoc-uml-diagrams-maven/
As follows my 3 tries of configuration, just in case you want to confirm which one is better by yourself:
1st try : UmlGraphDoc
It requires to install graphviz-2.38 (google it, it's easy to find) Diagrams are quite ugly, but understandable!!
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.10.2</version>
<reportSets>
<reportSet>
<id>uml</id>
<reports>
<report>javadoc</report>
</reports>
<configuration>
<name>uml</name>
<destDir>uml</destDir>
<quiet>true</quiet>
<aggregate>true</aggregate>
<show>private</show>
<doclet>org.umlgraph.doclet.UmlGraphDoc</doclet>
<docletArtifact>
<groupId>org.umlgraph</groupId>
<artifactId>umlgraph</artifactId>
<version>5.6.6</version>
</docletArtifact>
<additionalparam>
-inferrel -inferdep -quiet -hide java.* -hide org.eclipse.* -collpackages java.util.* -postfixpackage
-nodefontsize 9 -nodefontpackagesize 7 -attributes -types -visibility -operations -constructors
-enumerations -enumconstants -views
</additionalparam>
<useStandardDocletOptions>true</useStandardDocletOptions>
</configuration>
</reportSet>
</reportSets>
</plugin>
2nd try :Apiviz
It also requires to install graphviz-2.38 (Google it, it's easy to find) Diagrams generated are nicer than first option...
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.5</version>
<configuration>
<name>JavaDocUML</name>
<destDir>uml</destDir>
<doclet>org.jboss.apiviz.APIviz</doclet>
<stylesheetfile>${basedir}/src/main/resources/javadoc/javadoc-stylesheet.css</stylesheetfile>
<docletArtifact>
<groupId>org.jboss.apiviz</groupId>
<artifactId>apiviz</artifactId>
<version>1.3.2.GA</version>
</docletArtifact>
<useStandardDocletOptions>true</useStandardDocletOptions>
<charset>UTF-8</charset>
<encoding>UTF-8</encoding>
<docencoding>UTF-8</docencoding>
<breakiterator>true</breakiterator>
<version>true</version>
<author>true</author>
<keywords>true</keywords>
<additionalparam>
-sourceclasspath ${project.build.outputDirectory}
</additionalparam>
</configuration>
</plugin>
3th try (ywork) (I recommend this one)
Diagrams are much more understandable and wide more cooler :D It does not requires to install anything on your pc, you just need to download yworks-uml-doclet-3.0_02-jdk1.5 from its website and have it near your pom.xml, and using relative paths you can find it and use it as follows:
<properties>
<yworks.uml.path>${basedir}\..\..\tools\yworks-uml-doclet-3.0_02-jdk1.5</yworks.uml.path>
</properties>
.
.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.10.2</version>
<configuration>
<name>JavaDocUML</name>
<destDir>uml</destDir>
<!-- Doclet -->
<doclet>ydoc.doclets.YStandard</doclet>
<docletPath>${yworks.uml.path}/lib/ydoc.jar:${yworks.uml.path}/resources:${basedir}/target/your.application.jar</docletPath>
<additionalparam>-umlautogen</additionalparam>
<useStandardDocletOptions>true</useStandardDocletOptions>
<!-- bootclasspath required by Sun's JVM -->
<bootclasspath>${sun.boot.class.path}</bootclasspath>
<!-- General Javadoc settings -->
<doctitle>${project.name} (${project.version})</doctitle>
<show>private</show>
<!-- Styling -->
<stylesheetfile>${basedir}/src/main/resources/javadoc/javadoc-stylesheet.css</stylesheetfile>
<docfilessubdirs>true</docfilessubdirs>
<!-- Apple's JVM sometimes requires more memory -->
<additionalJOption>-J-Xmx1024m</additionalJOption>
<verbose>true</verbose>
</configuration>
</plugin>
In fact, the same UMLGraph that you mention includes an alternate doclet for the Javadoc tool that will generate UML diagrams as part of the Javadoc creation. I found this info here: http://wiki.wsmoak.net/cgi-bin/wiki.pl?UMLGraph
精彩评论