为什么 mvn javadoc:fix 显示成功,而在同一项目中 mvn javadoc:javadoc 之后失败?

Why mvn javadoc:fix shows success while in the same project mvn javadoc:javadoc fails afterwards?

我正在尝试将现有的 Javadoc 修复到 project

我是运行mvn javadoc:fix。它执行成功但没有修复一些 Javadocs。

Maven Javadoc插件配置:

[DEBUG] Configuring mojo org.apache.maven.plugins:maven-javadoc-plugin:3.2.0:fix from plugin realm ClassRealm[plugin>org.apache.maven.plugins:maven-javadoc-plugin:3.2.0, parent: jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29]
[DEBUG] Configuring mojo 'org.apache.maven.plugins:maven-javadoc-plugin:3.2.0:fix' with basic configurator -->
[DEBUG]   (f) comparisonVersion = (,1.2.0)
[DEBUG]   (f) defaultSince = 1.2.0
[DEBUG]   (f) defaultVersion = $Id: $Id
[DEBUG]   (f) encoding = UTF-8
[DEBUG]   (f) fixClassComment = true
[DEBUG]   (f) fixFieldComment = true
[DEBUG]   (f) fixMethodComment = true
[DEBUG]   (f) fixTags = all
[DEBUG]   (f) ignoreClirr = false
[DEBUG]   (f) includes = **\/*.java
[DEBUG]   (f) level = protected
[DEBUG]   (f) localRepository =       id: local
      url: file:///Users/dmytro/.m2/repository/
   layout: default
snapshots: [enabled => true, update => always]
 releases: [enabled => true, update => always]

[DEBUG]   (f) outputDirectory = /Users/dmytro/Documents/projects/amazon-mws-feeds-maven/src/main/java
[DEBUG]   (f) project = MavenProject: com.github.chameleontartu:amazon-mws-feeds-maven:1.2.0 @ /Users/dmytro/Documents/projects/amazon-mws-feeds-maven/pom.xml
[DEBUG]   (f) removeUnknownThrows = true
[DEBUG]   (f) session = org.apache.maven.execution.MavenSession@2f1ea80d
[DEBUG]   (f) settings = org.apache.maven.execution.SettingsAdapter@2ce56d1c
[DEBUG] -- end configuration --

mvn javadoc:javadoc 的部分输出:

[DEBUG] Configuring mojo org.apache.maven.plugins:maven-javadoc-plugin:3.2.0:javadoc from plugin realm ClassRealm[plugin>org.apache.maven.plugins:maven-javadoc-plugin:3.2.0, parent: jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29]
[DEBUG] Configuring mojo 'org.apache.maven.plugins:maven-javadoc-plugin:3.2.0:javadoc' with basic configurator -->
[DEBUG]   (f) applyJavadocSecurityFix = true
[DEBUG]   (f) author = true
[DEBUG]   (f) bootclasspathArtifacts = []
[DEBUG]   (f) bottom = Copyright © {inceptionYear}–{currentYear} {organizationName}. All rights reserved.
[DEBUG]   (f) breakiterator = false
[DEBUG]   (f) debug = false
[DEBUG]   (s) destDir = apidocs
[DEBUG]   (f) detectJavaApiLink = true
[DEBUG]   (f) detectLinks = false
[DEBUG]   (f) detectOfflineLinks = false
[DEBUG]   (f) docencoding = UTF-8
[DEBUG]   (f) docfilessubdirs = false
[DEBUG]   (f) docletArtifact = groupId = 'null'
artifactId = 'null'
version = 'null'
[DEBUG]   (f) docletArtifacts = []
[DEBUG]   (f) doctitle = Amazon MWS :: Feeds 1.2.0 API
[DEBUG]   (f) encoding = UTF-8
[DEBUG]   (f) failOnError = true
[DEBUG]   (f) failOnWarnings = false
[DEBUG]   (f) includeDependencySources = false
[DEBUG]   (f) includeTransitiveDependencySources = false
[DEBUG]   (f) isOffline = false
[DEBUG]   (f) javaApiLinks = {}
[DEBUG]   (f) javadocDirectory = /Users/dmytro/Documents/projects/amazon-mws-feeds-maven/src/main/javadoc
[DEBUG]   (f) javadocOptionsDir = /Users/dmytro/Documents/projects/amazon-mws-feeds-maven/target/javadoc-bundle-options
[DEBUG]   (f) keywords = false
[DEBUG]   (f) links = []
[DEBUG]   (f) linksource = false
[DEBUG]   (f) localRepository =       id: local
      url: file:///Users/dmytro/.m2/repository/
   layout: default
snapshots: [enabled => true, update => always]
 releases: [enabled => true, update => always]

[DEBUG]   (f) mojo = org.apache.maven.plugins:maven-javadoc-plugin:3.2.0:javadoc {execution: default-cli}
[DEBUG]   (f) nocomment = false
[DEBUG]   (f) nodeprecated = false
[DEBUG]   (f) nodeprecatedlist = false
[DEBUG]   (f) nohelp = false
[DEBUG]   (f) noindex = false
[DEBUG]   (f) nonavbar = false
[DEBUG]   (f) nooverview = false
[DEBUG]   (f) nosince = false
[DEBUG]   (f) notimestamp = false
[DEBUG]   (f) notree = false
[DEBUG]   (f) offlineLinks = []
[DEBUG]   (f) old = false
[DEBUG]   (f) outputDirectory = /Users/dmytro/Documents/projects/amazon-mws-feeds-maven/target/apidocs
[DEBUG]   (f) overview = /Users/dmytro/Documents/projects/amazon-mws-feeds-maven/src/main/javadoc/overview.html
[DEBUG]   (f) project = MavenProject: com.github.chameleontartu:amazon-mws-feeds-maven:1.2.0 @ /Users/dmytro/Documents/projects/amazon-mws-feeds-maven/pom.xml
[DEBUG]   (f) quiet = true
[DEBUG]   (f) reactorProjects = [MavenProject: com.github.chameleontartu:amazon-mws-feeds-maven:1.2.0 @ /Users/dmytro/Documents/projects/amazon-mws-feeds-maven/pom.xml]
[DEBUG]   (s) reportOutputDirectory = /Users/dmytro/Documents/projects/amazon-mws-feeds-maven/target/site/apidocs
[DEBUG]   (f) resourcesArtifacts = []
[DEBUG]   (f) serialwarn = false
[DEBUG]   (f) session = org.apache.maven.execution.MavenSession@7d78f3d5
[DEBUG]   (f) settings = org.apache.maven.execution.SettingsAdapter@a4b5ce3
[DEBUG]   (f) show = protected
[DEBUG]   (f) skip = false
[DEBUG]   (f) source = 1.6
[DEBUG]   (f) sourceDependencyCacheDir = /Users/dmytro/Documents/projects/amazon-mws-feeds-maven/target/distro-javadoc-sources
[DEBUG]   (f) splitindex = false
[DEBUG]   (f) staleDataPath = /Users/dmytro/Documents/projects/amazon-mws-feeds-maven/target/maven-javadoc-plugin-stale-data.txt
[DEBUG]   (f) stylesheet = java
[DEBUG]   (f) tagletArtifact = groupId = 'null'
artifactId = 'null'
version = 'null'
[DEBUG]   (f) tagletArtifacts = []
[DEBUG]   (f) taglets = []
[DEBUG]   (f) tags = []
[DEBUG]   (f) use = true
[DEBUG]   (f) useStandardDocletOptions = true
[DEBUG]   (f) validateLinks = false
[DEBUG]   (f) verbose = false
[DEBUG]   (f) version = true
[DEBUG]   (f) windowtitle = Amazon MWS :: Feeds 1.2.0 API
[DEBUG] -- end configuration --
[DEBUG] Found Java API link: https://docs.oracle.com/javase/6/docs/api/
[INFO] No previous run data found, generating javadoc.
[DEBUG] /Users/dmytro/.sdkman/candidates/java/current/bin/javadoc @options @packages
[INFO] 
100 errors
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  4.642 s
[INFO] Finished at: 2020-08-06T15:55:56+02:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-javadoc-plugin:3.2.0:javadoc (default-cli) on project amazon-mws-feeds-maven: An error has occurred in Javadoc report generation: 
[ERROR] Exit code: 1 - /Users/dmytro/Documents/projects/amazon-mws-feeds-maven/src/main/java/com/amazonaws/mws/feeds/model/GetReportRequestCountResponse.java:13: error: bad use of '>'
[ERROR]  * <complexType>
[ERROR]                   ^
[ERROR] /Users/dmytro/Documents/projects/amazon-mws-feeds-maven/src/main/java/com/amazonaws/mws/feeds/model/GetReportRequestCountResponse.java:14: error: bad use of '>'
[ERROR]  *   <complexContent>
[ERROR]                        ^
[ERROR] /Users/dmytro/Documents/projects/amazon-mws-feeds-maven/src/main/java/com/amazonaws/mws/feeds/model/GetReportRequestCountResponse.java:15: error: bad use of '>'
[ERROR]  *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
[ERROR]                                                                        ^
[ERROR] /Users/dmytro/Documents/projects/amazon-mws-feeds-maven/src/main/java/com/amazonaws/mws/feeds/model/GetReportRequestCountResponse.java:16: error: bad use of '>'
[ERROR]  *       <sequence>
[ERROR]                      ^
[ERROR] /Users/dmytro/Documents/projects/amazon-mws-feeds-maven/src/main/java/com/amazonaws/mws/feeds/model/GetReportRequestCountResponse.java:17: error: bad use of '>'
[ERROR]  *         <element ref="{http://mws.amazonaws.com/doc/2009-01-01/}GetReportRequestCountResult"/>
[ERROR]                                                                                                    ^
[ERROR] /Users/dmytro/Documents/projects/amazon-mws-feeds-maven/src/main/java/com/amazonaws/mws/feeds/model/GetReportRequestCountResponse.java:18: error: bad use of '>'
[ERROR]  *         <element ref="{http://mws.amazonaws.com/doc/2009-01-01/}ResponseMetadata"/>
[ERROR]                                                                                         ^
[ERROR] /Users/dmytro/Documents/projects/amazon-mws-feeds-maven/src/main/java/com/amazonaws/mws/feeds/model/GetReportRequestCountResponse.java:19: error: bad use of '>'
[ERROR]  *       </sequence>
[ERROR]                       ^
[ERROR] /Users/dmytro/Documents/projects/amazon-mws-feeds-maven/src/main/java/com/amazonaws/mws/feeds/model/GetReportRequestCountResponse.java:20: error: bad use of '>'
[ERROR]  *     </restriction>
[ERROR]                        ^
[ERROR] /Users/dmytro/Documents/projects/amazon-mws-feeds-maven/src/main/java/com/amazonaws/mws/feeds/model/GetReportRequestCountResponse.java:21: error: bad use of '>'
[ERROR]  *   </complexContent>
[ERROR]                         ^
[ERROR] /Users/dmytro/Documents/projects/amazon-mws-feeds-maven/src/main/java/com/amazonaws/mws/feeds/model/GetReportRequestCountResponse.java:22: error: bad use of '>'
[ERROR]  * </complexType>
[ERROR]                    ^
[ERROR] /Users/dmytro/Documents/projects/amazon-mws-feeds-maven/src/main/java/com/amazonaws/mws/feeds/model/GetReportRequestCountResponse.java:25: error: self-closing element not allowed
[ERROR]  * <p/>
[ERROR]    ^

在类似的项目中,在它起作用之前我只是不明白我做错了什么?

Maven/Java 详情:

$ mvn --version
Apache Maven 3.6.1 (d66c9c0b3152b2e69ee9bac180bb8fcc8e6af555; 2019-04-04T21:00:29+02:00)
Maven home: /Users/dmytro/.sdkman/candidates/maven/current
Java version: 11.0.2, vendor: Oracle Corporation, runtime: /Users/dmytro/.sdkman/candidates/java/11.0.2-open
Default locale: en_GB, platform encoding: UTF-8
OS name: "mac os x", version: "10.15.6", arch: "x86_64", family: "mac"

AWS 很可能使用 JAXB 来生成您的 Web 服务模型。

JAXB 有一个 issue,它在生成 Java 工件时没有正确地使用 gt; 转义 > 符号。

在 JDK 1.8 之前,这不是问题。

但是,自 JDK 8 起,javadoc 工具包括 doclint。这个新部分将检查您的代码是否符合 HTML 4.01 specification 并会为它发现的每个不符合项生成错误。

除其他外,它会报告 above-mentioned 问题和其他 non-conformities 导致您的 maven 项目中的 javadoc:javadoc 目标失败的错误。

This excelent article 详细解释了 javadoc 工具中的这一变化。

为避免该错误,成功生成文档并将工件部署到 Maven Central,您可以修改 javadoc maven 插件配置并禁用 doclint:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-javadoc-plugin</artifactId>
    <version>${maven-javadoc-plugin.version}</version>
    <configuration>
        <attach>true</attach>
        <source>${jdk.version}</source>
        <!--                        <quiet>true</quiet>-->
        <detectOfflineLinks>false</detectOfflineLinks>
        <encoding>${project.build.sourceEncoding}</encoding>
        <doclint>none</doclint>
    </configuration>
</plugin>

请注意包含 <doclint> 元素。

您可以完全禁用 doclint(如示例中所示),或将其使用限制为 certain groups

这个谜题只剩下一块拼图了:为什么 javadoc: fix 目标没有修复这些错误。老实说,我无法给您答案:我不知道这是不是错误(我猜不是),或者只是该工具无法修复此类错误。我希望有人能阐明这个问题。