Sunday, January 1, 2012

Reverse-engineering - UML


Generating UML Diagramns with Maven
  1. Install Graphviz. After installation confirm that it is part of your PATH.
  2. Configure your maven pom files to make sure that you can get to the following repository: http://mirrors.ibiblio.org/pub/mirrors/maven2 because it has the second piece of the puzzle, the binaries for UMLGraph. You can see all the options for use in <additionalparam/> here.
  3. To generate UML diagrams as part of the "mvn javadoc:javadoc" command, add the following (+/-) to your pom.xml file's <build/> section.
   <reporting>
            <plugins>
                  <plugin>
                        <artifactId>maven-javadoc-plugin</artifactId>
                        <version>2.8</version>
                        <configuration>
                              <links>
                                    <link>http://java.sun.com/javase/6/docs/api/</link>
                              </links>
                              <detectOfflineLinks />
                              <aggregate>true</aggregate>
                              <doclet>org.umlgraph.doclet.UmlGraphDoc</doclet>
                              <docletArtifact>
                                    <groupId>org.umlgraph</groupId>
                                    <artifactId>doclet</artifactId>
                                    <version>5.1</version>
                              </docletArtifact>
                              <additionalparam>-operations</additionalparam>
                              <additionalparam>-qualify</additionalparam>
                              <additionalparam>-types</additionalparam>
                              <additionalparam>-visibility</additionalparam>
                              <additionalparam>-collpackages</additionalparam>
                              <additionalparam>-views</additionalparam>
                              <useStandardDocletOptions>true</useStandardDocletOptions>
                              <show>private</show>
                        </configuration>
                  </plugin>
                  <plugin>
                        <artifactId>maven-pmd-plugin</artifactId>
                        <version>2.6</version>
                        <!-- TODO: choose appropriate rulesets -->
                        <configuration>
                              <targetJdk>1.6</targetJdk>
                        </configuration>
                  </plugin>
            </plugins>
      </reporting>
       5.    Run mvn javadoc:aggregate to generate the Project documentation.
That's it, you should now be reaping the benefits as your javadocs will have UML diagrams inside each class's landing page.


No comments:

Post a Comment