I have a multimodule java project built with Maven to which I want to generate javadocs with javadoc:aggregate
. The project structure looks like:
我有一个用Maven构建的多模块java项目,我想用javadoc:aggregate生成javadocs。项目结构如下:
parent
├─lomboklib
└─other
I am also using Project Lombok to generate some methods in the project. I have successfully configured it to work with single modules by first running delombok with the Lombok maven plugin. For single modules (lomboklib), this will generate source code in
我也使用Project Lombok在项目中生成一些方法。通过首先使用Lombok maven插件运行delombok,我已成功将其配置为使用单个模块。对于单个模块(lomboklib),这将生成源代码
target/generated-sources/delombok
which is then processed by maven-javadoc-plugin and the javadoc tool. This was originally solved in This SO question.
然后由maven-javadoc-plugin和javadoc工具处理。这最初是在这个SO问题中解决的。
How can I configure the javadoc:aggregate
report to also use the generated sources?
如何配置javadoc:aggregate报告以使用生成的源?
I've put up a sandbox of the problem with all the module definitions in Github. Ideally, I should be able to run
我用Github中的所有模块定义提出了问题的沙箱。理想情况下,我应该能够运行
mvn clean compile javadoc:aggregate
In the parent project, and have the whole thing compile and get javadocs for the entire project.
在父项目中,让整个项目编译并获取javadocs。
3 个解决方案
#1
2
I created a workaround build configuration that will create aggregated javadocs from generated sources, although the call sequence has two steps:
我创建了一个解决方法构建配置,它将从生成的源创建聚合的javadoc,尽管调用序列有两个步骤:
mvn package
mvn -N pre-site
The build configuration is now published in Github. The current version only supports a project tree of depth one, but can of course be modified. It works by gathering the dependencies under the parents target
directory and then running the included Ant script.
构建配置现在在Github中发布。当前版本仅支持深度为1的项目树,但当然可以进行修改。它的工作原理是收集父目标目录下的依赖项,然后运行包含的Ant脚本。
Finally, if running under Jenkins, the mvn -N pre-site
can be invoked in the same job through Execute shell post step. Publishing the javadocs in our version of Jenkins required using the post-build action "Use publishers from another project".
最后,如果在Jenkins下运行,可以通过Execute shell post步骤在同一作业中调用mvn -N pre-site。使用构建后操作“使用其他项目中的发布者”,需要在我们的Jenkins版本中发布javadoc。
#2
1
I downloaded the example project from Github to recreate your problem and discovered that it was because the lombok-maven-plugin
was configured unnecessarily at the top-level pom -- it is only needed for the module that contains lombok code. By simply removing that configuration, javadoc:aggregate
behaves as expected.
我从Github下载了示例项目以重新创建您的问题,并发现这是因为lombok-maven-plugin在顶层pom中被不必要地配置 - 只有包含lombok代码的模块才需要它。只需删除该配置,javadoc:aggregate就会按预期运行。
#3
0
I'm having this same problem, and I've been able to work around it by referencing the source paths directly from the parent project.
我遇到了同样的问题,我已经能够通过直接从父项目引用源路径来解决它。
Try this configuration for your parent pom's maven-javadoc-plugin.
为您的父pom的maven-javadoc-plugin尝试此配置。
<configuration>
<sourcepath>
lomboklib/target/generated-sources/delombok;
other/target/generated-sources/delombok
</sourcepath>
</configuration>
It's really not ideal. It feels like a bit of a hack.
这真的不太理想。这感觉有点像黑客。
#1
2
I created a workaround build configuration that will create aggregated javadocs from generated sources, although the call sequence has two steps:
我创建了一个解决方法构建配置,它将从生成的源创建聚合的javadoc,尽管调用序列有两个步骤:
mvn package
mvn -N pre-site
The build configuration is now published in Github. The current version only supports a project tree of depth one, but can of course be modified. It works by gathering the dependencies under the parents target
directory and then running the included Ant script.
构建配置现在在Github中发布。当前版本仅支持深度为1的项目树,但当然可以进行修改。它的工作原理是收集父目标目录下的依赖项,然后运行包含的Ant脚本。
Finally, if running under Jenkins, the mvn -N pre-site
can be invoked in the same job through Execute shell post step. Publishing the javadocs in our version of Jenkins required using the post-build action "Use publishers from another project".
最后,如果在Jenkins下运行,可以通过Execute shell post步骤在同一作业中调用mvn -N pre-site。使用构建后操作“使用其他项目中的发布者”,需要在我们的Jenkins版本中发布javadoc。
#2
1
I downloaded the example project from Github to recreate your problem and discovered that it was because the lombok-maven-plugin
was configured unnecessarily at the top-level pom -- it is only needed for the module that contains lombok code. By simply removing that configuration, javadoc:aggregate
behaves as expected.
我从Github下载了示例项目以重新创建您的问题,并发现这是因为lombok-maven-plugin在顶层pom中被不必要地配置 - 只有包含lombok代码的模块才需要它。只需删除该配置,javadoc:aggregate就会按预期运行。
#3
0
I'm having this same problem, and I've been able to work around it by referencing the source paths directly from the parent project.
我遇到了同样的问题,我已经能够通过直接从父项目引用源路径来解决它。
Try this configuration for your parent pom's maven-javadoc-plugin.
为您的父pom的maven-javadoc-plugin尝试此配置。
<configuration>
<sourcepath>
lomboklib/target/generated-sources/delombok;
other/target/generated-sources/delombok
</sourcepath>
</configuration>
It's really not ideal. It feels like a bit of a hack.
这真的不太理想。这感觉有点像黑客。