Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use javadoc:aggregate properly in multi-module maven project?

This is my parent pom.xml file (part of it) in a multi-module project:

...
<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-javadoc-plugin</artifactId>
        </plugin>
    </plugins>
</build>
...

This plugin is inherited in all sub-modules and I don't think it's a correct approach. When I'm running mvn javadoc:aggregate the documentation is generated in target/site/apidoc, but the log is full of warnings:

...
[WARNING] Removing: aggregate from forked lifecycle, 
to prevent recursive invocation.
...

What am I doing wrong?

like image 611
yegor256 Avatar asked Aug 04 '10 09:08

yegor256


1 Answers

You need to enable aggregation for this plugin:

  <plugin>
    <artifactId>maven-javadoc-plugin</artifactId>
    <configuration>
      <aggregate>true</aggregate> <!-- this enables aggretation -->
    </configuration>
  </plugin>

On the commandline type:

mvn javadoc:aggregate

Edit:

Okay, I did some digging into maven plugin's jira and found that all the javadoc plugin mojos have been annotated with @aggregator. But there seem to be problems with maven's aggregator the issue for which has been filed here

There are also related bugs here and here and some more

This seems to be a blocker issue with maven's aggregator since some plugins like e.g. clover wont run.

To to summarize, you are doing nothing wrong

Just switch back to earlier versions of maven-javadoc-plugin that does not use @aggregator mojo annotation and you will not get the warnings (unless you are using certain feature of the javadoc plugin thats not available in earlier version)

On a side note, If you run the javadoc plugin as report then the @aggregator is ignored.

like image 197
naikus Avatar answered Nov 15 '22 10:11

naikus