2017-09-23 98 views
3

我有一個使用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

0時
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> 

回答

0

雖然試圖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時,跳過測試源代,因此您的構建成功。

...爲 項目生成測試Javadoc文件。它執行標準的Javadoc工具並支持工具使用的參數 ,而不會再次生成生成測試源 階段。請注意,此目標確實需要在網站生成之前生成測試源 通過調用mvn clean deploy site

另一方面javadoc:test-javadoc再次編譯測試源並記錄錯誤。

生成項目的測試Javadoc文件。它執行標準的Javadoc工具 並支持該工具使用的參數。


所有的,與一組報告的<reportSets>

多個規格,每一個都具有(可能) 不同的配置。這是與構建中的 <execution>平行的報告。

no-fork型兩種,你可以嘗試包括test-javadoc如在<reportSet>報告來解決這一個。

+0

但這個問題沒有編譯器問題。這些問題只是拋出了拋出異常的javadoc。 - 即使在運行'test-javadoc-no-fork'時,javadoc工具也會識別該問題(它會生成警告),但它不會停止構建。 – Ralph

+0

@Ralph雅可能我最初弄錯了。試圖重現我的測試和主要每個類相同,我無法得到這兩個命令的失敗。你也可以嘗試將'test-javadoc'作爲報告之一,看看是否有幫助。 – nullpointer

相關問題