当模块名称与 artifactId 不同时 JPMS 模块的 Javadoc

Javadoc for JPMS modules when module name is different from artifactId

我有一个带有两个 jpms 模块的示例 project。是一父二子maven项目

父 pom:

...
<modules>
    <module>foo.api</module>
    <module>foo.impl</module>
</modules>
...

API 模块 pom:

...
<groupId>com.foo</groupId>
<artifactId>foo.api</artifactId>
...

API 模块信息:

module com.foo.api {
    requires org.slf4j;
    exports com.foo.api;
}

这些是我对 maven-javadoc-plugin 的设置(在父 pom 中):

   <reporting>
         <excludeDefaults>true</excludeDefaults>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-javadoc-plugin</artifactId>
                <version>3.3.0</version>
                <reportSets>
                  <reportSet>
                    <reports>
                      <report>javadoc-no-fork</report>
                      <report>test-javadoc-no-fork</report>
                    </reports>
                  </reportSet>
                </reportSets>
                <configuration>
                    <doclint>none</doclint>
                    <dependencySourceIncludes>
                       <dependencySourceInclude>com.foo:${project.artifactId}</dependencySourceInclude>
                    </dependencySourceIncludes>
                    <doctitle>Title - ${project.version}</doctitle>
                    <includeDependencySources>false</includeDependencySources>
                    <windowtitle>Title</windowtitle>
                    <additionalJOptions>
                        <additionalJOption>--no-module-directories</additionalJOption>
                    </additionalJOptions>
                </configuration>
              </plugin>
        </plugins>
    </reporting>

当我 运行 mvn javadoc:javadoc 我得到:

Failed to execute goal org.apache.maven.plugins:maven-javadoc-plugin:3.2.0:javadoc (default-cli) on project foo.api: An error has occurred in Javadoc report generation: 
Exit code: 1 - error: module not found: com.foo.api

谁能告诉我怎么解决?

我找到了解决方案。在模块的情况下,javadoc 需要编译模块描述符,因此有必要执行 mvn compile javadoc:javadoc 而不是 mvn javadoc:javadoc