How to draw UML in Java documents?

I'm trying to find a tool / framework / plug-in that allows me to draw UML diagrams in my JavaDocs annotations I don't need to reverse engineer automated UML images (effectively provided by UML graph and others) I want to be able to create my own custom charts Can you suggest?

Solution

I tried three methods to generate UML diagrams in JavaDocs using maven Javadoc plugin and doclets:

1)UmlGraphDoc

2)apiviz

3)yworks

I can say that the best option is option 3, because it is the only option that does not need to be installed in the development PC

For umlgraphdoc and apiviz (two doclets), they need to install graphviz

It's easy to install it and configure maven Javadoc plugin, but since they require a separate application, it will make UML generation a little dirty, because if you want to include UML generation in your Maven life cycle, all other developers will need to install graphviz (dependency I really want to avoid)

Anyway, this link has the method I follow, using yworks (it works):

> http://archive.keyboardplaying.org/2012/05/29/javadoc-uml-diagrams-maven/

Here are my 3 attempts to configure in case you want to confirm which is better:

First attempt: umlgraphdoc

It needs to install graphviz-2.38 (Google it, easy to find). The chart is 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>

Second attempt: apiviz

It also needs to install graphviz-2.38 (Google it, easy to find). The generated chart is better than the 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>

Third attempt (ywork) (I recommend this)

The chart is easier to understand and broader: D it doesn't need to install anything on your computer. You just need to download yworks-uml-doclet-3.0 from its website_ 02-jdk1. 5 and put it in your POM XML and use the relative path. 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>
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>