0

I would like to set up the maven java-docs plugin in my project to create an aggregated report that includes only some classes from some of the modules and output the report to a folder of choice.

I have already tried to work with the Maven documentation here however whats indicated there does not seem to work for me. I have tried the following configuration in the past and ran it as: mvn javadoc:javadoc, or even javadoc:aggregate with the following parent/child pom configurations:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-javadoc-plugin</artifactId>
    <version>3.1.0</version>
    <inherited>false</inherited>
    <configuration>
        <!-- Default configuration for all reports -->
    </configuration>
    <executions>
        <execution>
            <id>aggregate</id>
            <goals>
                <goal>aggregate</goal>
            </goals>
            <phase>package</phase>
            <configuration>
            </configuration>
        </execution>
    </executions>
</plugin>

I have used something like this in the past:

parent pom.xml

<pluginManagement>
    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-javadoc-plugin</artifactId>
        <configuration>
            <skip>true</skip>
        </configuration>
    </plugin>
</pluginManagement>
...
<build>
    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-javadoc-plugin</artifactId>
        <version>3.1.0</version>
        <configuration>
            <!-- Default configuration for all reports -->
        </configuration>
        <executions>
            <execution>
                <id>aggregate</id>
                <goals>
                    <goal>aggregate</goal>
                </goals>
                <phase>site</phase>
                <configuration>
                    <skip>false</skip>
                </configuration>
            </execution>
        </executions>
    </plugin>
</build>

Desired child module pom.xml

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-javadoc-plugin</artifactId>
            <configuration>
                <skip>false</skip>
                <noqualifier>all</noqualifier>
                <sourceFileIncludes>
                    <include>**\/\Class1.java</include>
                    <include>**\/\Class2.java</include>
                    <include>**\/\Interface3.java</include>
                    <include>**\/\Class4.java</include>
                </sourceFileIncludes>
                <reportOutputDirectory>${project.parent.basedir}/..</reportOutputDirectory>
                <destDir>java-docs</destDir>
            </configuration>
        </plugin>
    </plugins>
</build>

This configuration works fine if I am only generating from one single module, however once another child module is picked and configured as the one shown before, running mvn javadoc:aggregate continues to generate the docs for module 1 only, and module 2 gets ignored(or maybe even overriden)

Has anyone worked with a similar scenario, a multi module project structured like so:

ParentFolder
. . . module1
        pom.xml
. . . module3
        pom.xml
. . . module4
        pom.xml
pom.xml

and have succeeded generating an aggregated java docs report using the maven java docs plugin, while excluding some classes and outputting the results to a folder of their choice? Any help with this would be greatly appreciated!

Carlos Luis
  • 213
  • 2
  • 17

1 Answers1

1

Do you have one parent POM that contains both plugin config for the child POMs, and module definitions? If so, you may want to consider separating this POM into a separate aggregator (module definitions) and parent (anything else in the current POM that should be shared with children).

This answer goes into a lot more detail about Maven build order and why the behavior occurs.

The aggregator POM will also hold the configuration for child module data that should be aggregated, such as Javadoc.

user944849
  • 14,524
  • 2
  • 61
  • 83