mvn javadoc:fix 成功显示,而在同一项目中 mvn javadoc:javadoc 后来失败了。

huangapple go评论82阅读模式
英文:

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

问题

我正在尝试修复现有的 Javadocs,链接到项目

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

Maven Javadoc 插件的配置:

[DEBUG] 配置 mojo org.apache.maven.plugins:maven-javadoc-plugin:3.2.0:fix,来自插件 realm ClassRealm[plugin>org.apache.maven.plugins:maven-javadoc-plugin:3.2.0, parent: jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29]
[DEBUG] 配置 mojo 'org.apache.maven.plugins:maven-javadoc-plugin:3.2.0:fix',使用基本配置器 -->
[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] -- 配置结束 --

mvn javadoc:javadoc 的一部分输出:

[DEBUG] 配置 mojo org.apache.maven.plugins:maven-javadoc-plugin:3.2.0:javadoc,来自插件 realm ClassRealm[plugin>org.apache.maven.plugins:maven-javadoc-plugin:3.2.0, parent: jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29]
[DEBUG] 配置 mojo 'org.apache.maven.plugins:maven-javadoc-plugin:3.2.0:javadoc',使用基本配置器 -->
[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

<details>
<summary>英文:</summary>

I am trying to fix existing Javadocs into the [project](https://github.com/ChameleonTartu/amazon-mws-feeds-maven).

I am running `mvn javadoc:fix`. It executes successfully BUT doesn&#39;t fix some of the Javadocs.

Configuration of Maven Javadoc plugin:

[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 --


Part of the output for `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 &#169; {inceptionYear}&#x2013;{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] * &lt;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] * &lt;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] * &lt;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] * &lt;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] * &lt;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] * &lt;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] * &lt;/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] * &lt;/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] * &lt;/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] * &lt;/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] ^


On similar projects, before it worked I just don&#39;t understand what am I doing wrong?

Maven/Java details:

$ 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"


</details>


# 答案1
**得分**: 3

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

JAXB存在一个问题,即在生成Java构件时,它无法正确转义```&gt;```符号为```gt;```。

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

但是,自JDK 8以来,```javadoc```工具包括了```doclint```。这个新部分将检查您的代码是否符合[HTML 4.01规范](http://www.w3.org/TR/REC-html40/),并对每个不合规的地方生成错误。

其中,它将报告上述问题以及其他导致您的Maven项目中的```javadoc:javadoc```目标失败的不合规之处。

[这篇优秀的文章](https://blog.joda.org/2014/02/turning-off-doclint-in-jdk-8-javadoc.html)详细解释了```javadoc```工具中的这一变化。

为了避免这个错误,成功生成您的文档并将您的构件部署到Maven中央仓库,您可以修改您的javadoc Maven插件配置并禁用```doclint```:

```xml
<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>

请注意&lt;doclint&gt;元素的添加。

您可以完全禁用doclint(就像示例中一样),或将其限制在certain groups中使用。

在这个谜题中只剩下一个问题:为什么javadoc:fix目标无法修复这些错误。老实说,我不能给您一个答案:我不知道这是否是一个错误(我猜不是),还是工具不能修复这些类型的错误。我希望有人能在这个问题上提供一些启发。

英文:

AWS most likely uses JAXB to generate your web service model.

JAXB has an issue consisting in that it does not correctly escape the &gt; symbol with gt; when generating the Java artifacts.

Before JDK 1.8, this was not a problem.

But, since JDK 8, the javadoc tool includes doclint. This new part will check your code for compliance with the HTML 4.01 specification and will generate errors for every nonconformity it finds.

Among others, it will report the error of the above-mentioned problem and other non-conformities that cause the javadoc:javadoc goal in your maven project to fail.

This excelent article explains in great detail this change in the javadoc tool.

To avoid that error, successfully generate your documentation, and deploy your artifact to Maven central, you can modify your javadoc maven plugin configuration and disable doclint:

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

Please, observe the inclusion of the &lt;doclint&gt; element.

You can disable doclint completely (like in the example), or limit its use to certain groups.

There is only one piece left to fit into this puzzle: why doesn't the javadoc: fix goal fix those errors. Honestly, I can't give you an answer: I don't know if it's a bug (I guess not) or just that the tool doesn't fix those kinds of errors. I hope someone can shed some light on the subject.

huangapple
  • 本文由 发表于 2020年8月6日 22:03:08
  • 转载请务必保留本文链接:https://go.coder-hub.com/63285289.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定