javajavadocmaven-javadoc-plugin

Aggregate javadoc by packages


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:

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

Solution

  • 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>