0

Say I have the following package structure:

enter image description here

When I generate the javadoc, I will get the following under index.html:

enter image description here

I find that inconvenient for two reasons:

  • You can't really explore the classes by package, since all the list is flat (it's not like navigating a tree of folders)
  • The package-info.java only appears at the level of com.company.framework package (which contains no class) and the other two sub-packages which actually contain classes have an empty description.

I would like to somehow "aggregate" (or collapse?) the package so that I can get only com.company.framework, and then expanding this I can get just a and b.

Is that achievable using Javadoc?

My setup if needed:

maven plugin:

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-javadoc-plugin</artifactId>
            <version>3.1.0</version>
            <configuration>
                <javadocExecutable>${java.home}/bin/javadoc</javadocExecutable>
                <overview>${basedir}/javadoc/overview.html</overview>
            </configuration>
            <executions>
                <execution>
                    <id>aggregate</id>
                    <goals>
                        <goal>aggregate</goal>
                    </goals>
                    <configuration>
                        <reportOutputDirectory>${basedir}/framework-doc/</reportOutputDirectory>
                    </configuration>
                </execution>
            </executions>
        </plugin>

The command I use to build the javadoc:

mvn javadoc:aggregate
Matteo NNZ
  • 11,930
  • 12
  • 52
  • 89

1 Answers1

0

Finally, the right place to look for was the Grouping Packages functionality of the javadoc maven plugin.

Official documentation: here

Sample:

    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-javadoc-plugin</artifactId>
        <version>3.1.0</version>
        <configuration>
            <javadocExecutable>${java.home}/bin/javadoc</javadocExecutable>
            <overview>${basedir}/javadoc/overview.html</overview>
            <groups>
               <group>
                   <title>Package A</title>
                   <packages>com.company.framework.a*</packages>
               </group>
            </groups>
        </configuration>
        <executions>
            <execution>
                <id>aggregate</id>
                <goals>
                    <goal>aggregate</goal>
                </goals>
                <configuration>
                    <reportOutputDirectory>${basedir}/framework-doc/</reportOutputDirectory>
                </configuration>
            </execution>
        </executions>
    </plugin>
Matteo NNZ
  • 11,930
  • 12
  • 52
  • 89