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

丶灬走出姿态 提交于 2019-12-01 16:21:04

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/3404322/how-to-use-javadocaggregate-properly-in-multi-module-maven-project

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!