收录日期:2019/10/18 22:08:41 时间:2009-11-11 00:03:14 标签:java,maven-2,documentation,uml,javadoc

I want to generate javadocs through maven's site generation plugin and I want to have automatic UML diagrams created and embedded in the javadoc.

The statsvn project uses yDoc to generate their UML documentation but I think they're using Maven1. yDoc is a commercial shareware product, so I'm unsure how the open source statsvn project integrates with it (or if there is a free version to use for javadoc generation).

Example svnstat yDoc javadoc: ChurnPageMaker.java

svnstat includes ydoc as a plugin to their Maven1 report generation: project.xml

    <reports>
            <report>maven-ydoc-plugin</report>
 ...
    </reports>

The yDoc documentation says you can use Maven2's custom javadoc doclet approach (but I can't figure out where to download yDoc or if it's free). It seems like the statsvn project is using yDoc so I'm guessing it's free?

Are there any other open source Javadoc doclet generators that integrate with Maven2 to generate javadocs with embedded class diagrams.

It looks like the APIViz doclet support Maven2 javadoc plugin to generate class diagrams in javadoc.

  <reporting>
    ...
    <plugins>
      ...
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-javadoc-plugin</artifactId>
        <version>2.5</version>
        <configuration>
          <doclet>org.jboss.apiviz.APIviz</doclet>
          <docletArtifact>
            <groupId>org.jboss.apiviz</groupId>
            <artifactId>apiviz</artifactId>
            <version>1.3.0.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>
      ...
    </plugins>
    ...
  </reporting>

For Maven 2, have a look at http://maven.apache.org/plugins/maven-javadoc-plugin/examples/alternate-doclet.html which describes how to include UmlGraph diagrams in the javadoc of your code (requires Graphviz binary on the PATH). Below a sample POM using UmlGraph as alternate doclet:

<project>
  ...
  <reporting> (or <build>)
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-javadoc-plugin</artifactId>
        <version>2.6.1</version>
        <configuration>
          <doclet>org.umlgraph.doclet.UmlGraphDoc</doclet>
          <!-- <docletPath>/path/to/UmlGraph.jar</docletPath> -->
          <docletArtifact>
            <groupId>org.umlgraph</groupId>
            <artifactId>doclet</artifactId>
            <version>5.1</version>
          </docletArtifact>
          <additionalparam>-views</additionalparam>
          <useStandardDocletOptions>true</useStandardDocletOptions>
        </configuration>
      </plugin>
    ...
    </plugins>
  </reporting> (or </build>)
  ...
</project>

I know you want java docs, but have you checked out Doxygen? Perhaps it can do what you want. Here's a question comparing Javadocs and Doxygen.