Auto-generation of UML Class Diagrams in Maven Projects

The yWorks UML Doclet is a handy Javadoc extension that automatically creates good-looking UML diagrams from Java classes and embeds them into the generated API documentation.

Although the tool is not free sofware, it’s Community Edition is available for free of charge under the following conditions:

The Community Edition of the Software is licensed to you free of charge. It comes without support and warranties of any kind. The Community Edition of the Software inserts a web link into your output files that points to the yWorks website. You may not change that link or prevent either display of the link or the intended use as means of navigation to get to the yWorks website in any way.

These terms are quite reasonable and you don’t have to pay a high price for such a great tool.

The functionality offered by the product is also available in Apache Maven projects via the Maven Javadoc Plugin. The following is a minimal POM that demonstrates how to use the doclet in Maven projects:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>my</groupId>
  <artifactId>project</artifactId>
  <packaging>jar</packaging>
  <version>1.0</version>
  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-site-plugin</artifactId>
        <version>3.0</version>
        <configuration>
          <reportPlugins>
            <plugin>
              <groupId>org.apache.maven.plugins</groupId>
              <artifactId>maven-project-info-reports-plugin</artifactId>
            </plugin>
            <plugin>
              <groupId>org.apache.maven.plugins</groupId>
              <artifactId>maven-javadoc-plugin</artifactId>
              <version>2.8.1</version>
              <configuration>
                <doclet>ydoc.doclets.YStandard</doclet>
                <docletPath>${yDoc.path}/lib/ydoc.jar:${yDoc.path}/lib/styleed.jar:${yDoc.path}/resources</docletPath>
                <additionalparam>-umlautogen</additionalparam>
              </configuration>
            </plugin>
          </reportPlugins>
        </configuration>
      </plugin>
    </plugins>
  </build>
</project>

Can’t wait to try it? Download and unpack the archive of the Community Edition, then run Maven with mvn site -DyDoc.path=PATH where PATH is the path of the directory that contains your yDoc installation. Alternatively, the path can also be given in the properties element of the POM:

<properties>
  <yDoc.path>PATH</yDoc.path>
</properties>

The screenshot below shows the appearance of the enhanced API documentation.

API documentation with auto-generated UML class diagram

Thanks to László Aszalós for recommending this excellent tool.

Advertisements
Tagged ,

2 thoughts on “Auto-generation of UML Class Diagrams in Maven Projects

  1. Sridhar says:

    Hello,

    This is Sridhar Goranti. I tried the same thing in my project.
    1. I downloaded yEd-3.10.zip and extracted in to c:\ drive and
    2. updated my pom.xml file with the below entry-

    org.apache.maven.plugins
    maven-javadoc-plugin
    2.8.1

    ydoc.doclets.YStandard
    ${yDoc.path}/lib/ydoc.jar:${yDoc.path}/lib/styleed.jar:${yDoc.path}/resources
    -umlautogen

    3. Executed below command from my command prompt:-
    mvn site -DyDoc.path=c:\yEd-3.10
    4. I ran my Mavn install from my application – it went successful

    But where can we see the UML diagrams, Is there any additional settings that we need to do, please help me here.

    Thanks & Regards,
    Sridhar Goranti
    USA

    • Sridhar says:

      Hello,

      I found the solution for the UML Diagrams where you can generate from the java source code, I used the objectaid.com and downloaded the plugin.

      http://www.objectaid.com/download

      1. I am able to generate the class diagrams and
      2. But when I try generate the sequence diagram from my java code, I am getting issue with Licence.

      No Licence was found for ‘com.objectaid.uml.seq’

      Please help me, If any one worked on similar that uses open source plugins / tools for the same.

      Thanks & Regards,
      Sridhar Goranti
      USA

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: