如何在多模块maven项目中正确使用javadoc:aggregate?

发布于 2024-09-13 04:04:22 字数 603 浏览 7 评论 0原文

这是我在多模块项目中的父 pom.xml 文件(其中一部分):

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

该插件在所有子模块中继承,我认为这不是正确的方法。当我运行 mvn javadoc:aggregate 时,文档在 target/site/apidoc 中生成,但日志中充满了警告:

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

我做错了什么?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

温柔戏命师 2024-09-20 04:04:22

您需要为此插件启用聚合:

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

在命令行上输入:

mvn javadoc:aggregate

编辑:

好的,我深入研究了 Maven 插件的 jira,发现所有 javadoc 插件 mojos 都已用 @aggregator 进行了注释。 提交了问题

但是maven的聚合器似乎存在问题,已在此处 还有相关错误此处这里 以及更多

这似乎是一个拦截器问题使用 maven 的聚合器,因为某些插件(例如 clover)无法运行。

总而言之,您没有做错任何事情

只需切换回不使用 @aggregator mojo 注释的 maven-javadoc-plugin 的早期版本,您将不会收到警告(除非您正在使用某些功能)早期版本中不可用的 javadoc 插件)

顺便说一句,如果您将 javadoc 插件作为报告运行,则 @aggregator 将被忽略。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文