Mark Crocker wrote on 2006-10-27 10:41:27:

> Mark Crocker wrote on 2006-10-10 08:30:19:

>> How do I get the maven-javadoc-plugin to include the test classes as
>> well as the runtime classes when generating Javadocs?

> I was hoping for something a little more like the jxr plugin, which
> creates TWO sets of cross reference sets... one for the main source
> code and one for the test source code.

> From the command line, this can be accomplished simply by using two
> commands for javadocs:

>  mvn javadoc:javadoc
>  mvn -Dsourcepath=src/test/java -DdestDir=target/site/testapidocs
> javadoc:javadoc

> The first simply generates the usual javadocs without test cases and
> the second does the test javadocs and puts them in the testapidocs
directory.

> Getting the same effect from the pom.xml is giving me trouble.  I'll
> follow-up when I've made some progress.

Well, I found that I could add:

      <reportSet>
            <id>test-html</id>
            <configuration>
                  <sourcepath>src/test/java</sourcepath>
                  <destDir>target/site/testapidocs</destDir>
                  <show>private</show>
            </configuration>
            <reports>
                  <report>javadoc</report>
            </reports>
      </reportSet>

and that would create a set of test documentation iff I had it as the first
report set.  However, the regular javadocs then refused to run and produced
the following message:

      [INFO] Skipped "JavaDocs" report, file "apidocs/index.html" already
exists for the English version.

The result was test Javadocs in the testapi directory and nothing but a
blank index.html in the apidocs directory.  If I reverse the order of the
report sets, then the regular main code javadocs works find and the test
javadocs are skipped altogether.

The solution was provided by [MJAVADOC-81]
(http://jira.codehaus.org/browse/MJAVADOC-81), which is basically to use
version 2.1 of the maven-javadoc-plugin.  However, it wasn't smooth sailing
as there were some significant, inconsistent, changes in some of the tags.
For example, using the destDir path above is won't work and using
${project.build.directory}/testapidocs in destDir would put the end result
in target/site/target/site/testapidocs (or something to that effect).
However, the sourcepath isn't relative anymore and does require
${basedir}/src/test/java to work.

I also can't really figure out how to use the new outputName tag.  I was
hoping that it would be used for the link to the uml/graph.dot file, but
instead the link is uml/index.html, which doesn't exist.

The whole javadoc report configuration ends up being:

      <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-javadoc-plugin</artifactId>
            <version>2.1</version>
            <reportSets>
                  <reportSet>
                        <id>html</id>
                        <configuration>
                              <show>private</show>

<doclet>gr.spinellis.umlgraph.doclet.UmlGraphDoc</doclet>
                              <docletArtifact>
                                    <groupId>gr.spinellis</groupId>
                                    <artifactId>UmlGraph</artifactId>
                                    <version>4.4</version>
                              </docletArtifact>
                              <additionalparam>
                                    -inferrel -inferdep -quiet -hide java.*
                                    -collpackages java.util.*
                                    -qualify -postfixpackage
                                    -nodefontsize 9
                                    -nodefontpackagesize 7
                              </additionalparam>
                        </configuration>
                        <reports>
                              <report>javadoc</report>
                        </reports>
                  </reportSet>
                  <reportSet>
                        <id>test-html</id>
                        <configuration>
                              <name>Test Javadocs</name>
                              <description>Javadocs for test source
code.</description>
                              <sourcepath>
${basedir}/src/test/java</sourcepath>
                              <!-- should use ${project.build.directory} or
                                   ${project.reporting.outputDirectory} ?!?
-->
                              <destDir>testapidocs</destDir>
                              <show>private</show>
                        </configuration>
                        <reports>
                              <report>javadoc</report>
                        </reports>
                  </reportSet>
                  <reportSet>
                        <id>uml</id>
                        <configuration>
                              <name>UML Graph</name>
                              <description>UML diagram generated by UML
Graph
                                          (requires
ZGRViewer).</description>
                              <outputName>uml/graph.dot</outputName>

<doclet>gr.spinellis.umlgraph.doclet.UmlGraph</doclet>
                              <docletArtifact>
                                    <groupId>gr.spinellis</groupId>
                                    <artifactId>UmlGraph</artifactId>
                                    <version>4.4</version>
                              </docletArtifact>
                              <additionalparam>-views</additionalparam>
                              <!-- should use ${project.build.directory} or
                                   ${project.reporting.outputDirectory} ?!?
-->
                              <destDir>uml</destDir>
                              <show>private</show>
                        </configuration>
                        <reports>
                              <report>javadoc</report>
                        </reports>
                  </reportSet>
            </reportSets>
      </plugin>


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to