gpt4 book ai didi

java - 是什么导致 maven-javadoc-plugin 目标 test-javadoc 因错误而失败,但 test-javadoc-no-fork 只是发出警告

转载 作者:行者123 更新时间:2023-12-04 16:37:31 32 4
gpt4 key购买 nike

我有一个带有 maven-javadoc-plugin 和 JDK8 的 Maven 项目。当我运行 mvn javadoc:test-javadoc 时,插件会报告文档错误并停止,但是当我运行 mvn javadoc:test-javadoc-no-fork 时,插件会运行成功,只有一些警告。

问题是不是如何修复或文档错误。该插件发现了需要修复的真实文档问题,因此报告的 mvn javadoc:test-javadoc 错误是正确的结果。

问题是:为什么 mvn javadoc:test-javadoc-no-fork 没有失败,而是像警告一样处理问题?


背景:

  • 该项目是一个多模块项目
  • Maven 版本:3.3.9
  • maven-javadoc-plugin:2.9.4(3.0.0-M1 出现相同的行为)
  • Java8

TracingServiceSpringTest 中的运动问题确实缺少针对抛出的 DatatypeConfigurationException

的文档
/** scenario: some text... **/
@Test
public void testImport() throws DatatypeConfigurationException {...

运行mvn javadoc:test-javadoc时的输出

[INFO]
[INFO] <<< maven-javadoc-plugin:2.10.4:test-javadoc (default-cli) < generate-test-sources @ agrovet-server <<<
[INFO]
[INFO] --- maven-javadoc-plugin:2.10.4:test-javadoc (default-cli) @ agrovet-server ---
[INFO]
...
3 errors
9 warnings
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] PROJECT ............................................ SUCCESS [ 1.131 s]
[INFO] PROJECT :: Client .................................. SUCCESS [ 43.908 s]
[INFO] PROJECT :: Server .................................. FAILURE [ 44.774 s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 01:36 min
[INFO] Finished at: 2017-09-23T21:33:33+02:00
[INFO] Final Memory: 96M/1573M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-javadoc-plugin:2.10.4:test-javadoc (default-cli) on project PROJECT-server: An error has occurred in Test JavaDocs report generation:
[ERROR] Exit code: 1 - F:\workspaces\PROJECT\PROJECT-server\src\test\java\com\example\PROJECT\infrastructure\TracingServiceSpringTest.java:389: warning:
no @throws for javax.xml.datatype.DatatypeConfigurationException
[ERROR] public void testImport() throws DatatypeConfigurationException {
[ERROR] ^
...
[ERROR]
[ERROR] Command line was: "C:\Program Files\Java\jdk1.8.0_121\jre\..\bin\javadoc.exe" @options @packages
[ERROR]
[ERROR] Refer to the generated Javadoc files in 'F:\workspaces\PROJECT\PROJECT-server\target\site\testapidocs' dir.
[ERROR] -> [Help 1]
[ERROR]

...

运行mvn javadoc:test-javadoc-no-fork时的输出

8 warnings
[WARNING] Javadoc Warnings
[WARNING] F:\workspaces\PROJECT\PROJECT-server\src\test\java\com\example\PROJECT\infrastructure\TracingServiceSpringTest:389: warning: no @throws for javax.xml.datatype.DatatypeConfigurationException
[WARNING] public void testImport() throws DatatypeConfigurationException {
[WARNING] ^
...
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] PROJECT ............................................ SUCCESS [ 0.454 s]
[INFO] PROJECT :: Client .................................. SUCCESS [ 0.011 s]
[INFO] PROJECT :: Server .................................. SUCCESS [ 6.763 [INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
...

相关 POM 部分,父级 pom.xml(完整的 pom 太大了,但这是唯一提到 maven-javadoc-plugin 的部分:

<dependencyManagement>
<dependencies>
...
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.10.4</version>
</plugin>
</dependencies>
</dependencyManagement>
...
<reporting>
<plugins>
...
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<reportSets>
<reportSet>
<reports>
<!--
javadoc-no-fork in order to prevent JavaDoc process from runing generate-source again
but this also requries that JavaDoc generation runs after compile: "mvn install site"
but not on a black project "mvn clean site"
-->
<report>javadoc-no-fork</report>
<report>test-javadoc-no-fork</report>
</reports>
</reportSet>
</reportSets>
</plugin>
</plugins>
</reporting>

最佳答案

同时尝试 Generate Javadoc without duplicate execution of phase generate-sources .从版本 2.10 开始,定义了两个新报告,javadoc-no-forktest-javadoc-no-fork不会触发 generate-sourcesgenerate-test-sources第二次再次相变。

当您使用选项 test-javadoc-no-fork 时测试源生成被跳过,因此您的构建成功。

...generates the test Javadoc files for the project. It executes the standard Javadoc tool and supports the parameters used by the tool without forking the generate-test-sources phase again. Note that this goal does require generation of test sources before site generation, e.g. by invoking mvn clean deploy site.

另一方面 javadoc:test-javadoc 再次编译测试源并记录错误。

generates the test Javadoc files for the project. It executes the standard Javadoc tool and supports the parameters used by the tool.


所有这些都与 <reportSets> 相关

Multiple specifications of a set of reports, each having (possibly) different configuration. This is the reporting parallel to an <execution> in the build.

类型都是no-fork ,您可以尝试包含 test-javadoc作为<reportSet>中的报告之一解决这个问题。

关于java - 是什么导致 maven-javadoc-plugin 目标 test-javadoc 因错误而失败,但 test-javadoc-no-fork 只是发出警告,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46383942/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com