我有一個使用maven-javadoc-plugin和JDK8的Maven項目。當我運行mvn javadoc:test-javadoc
時,插件報告文檔錯誤並停止,但是當我運行mvn javadoc:test-javadoc-no-fork
時,插件運行成功,並且只有一些警告。什麼原因導致maven-javadoc插件目標test-javadoc失敗,但test-javadoc-no-fork只是有警告
問題是不是如何解決或文檔錯誤。該插件發現了真正的文檔問題,需要修正,因此mvn javadoc:test-javadoc
的報告錯誤是正確的結果。
問題是:爲什麼mvn javadoc:test-javadoc-no-fork
不會失敗,但處理問題就像警告一樣?
背景:
- 該項目是一個多模塊項目
- Maven的版本:3.3.9
- Maven的Javadoc的插件: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>
但這個問題沒有編譯器問題。這些問題只是拋出了拋出異常的javadoc。 - 即使在運行'test-javadoc-no-fork'時,javadoc工具也會識別該問題(它會生成警告),但它不會停止構建。 – Ralph
@Ralph雅可能我最初弄錯了。試圖重現我的測試和主要每個類相同,我無法得到這兩個命令的失敗。你也可以嘗試將'test-javadoc'作爲報告之一,看看是否有幫助。 – nullpointer