2017-08-04 76 views
0

在春天啓動的項目,我使用Apache的POM插件的CheckStyle如下圖所示:Eclipse和Apache的CheckStyle插件對準

 <plugin> 
      <groupId>org.apache.maven.plugins</groupId> 
      <artifactId>maven-checkstyle-plugin</artifactId> 
      <version>2.17</version> 
      <executions> 
       <execution> 
        <id>default-cli</id> 
        <goals> 
         <goal>check</goal> 
        </goals> 
        <phase>validate</phase> 
       </execution> 
      </executions> 
      <configuration> 
       <configLocation>google_checks.xml</configLocation> 
       <consoleOutput>true</consoleOutput> 
       <failsOnError>true</failsOnError>      
      </configuration> 
     </plugin> 

在Eclipse Neon.1版本(4.6.1),我已經安裝了Eclipse的CheckStyle從下面的路徑插件:

Eclipse CheckStyle Plugin

固定的Eclipse插件強調所有Check作風問題之後,當我運行驗證行家的目標,我還是看到了進口依存度由M報相關的控制檯上許多檢查風格違規aven插件例如

D:\Data\Filter.java:4: warning: 'com.microsoft.aad.adal4j.AuthenticationContext' should be separated from previous import group. 
D:\Data\Filter.java:39: warning: Import statement for 'org.springframework.beans.factory.annotation.Value' is in the wrong order. Should be in the 'THIRD_PARTY_PACKAGE' group, expecting not assigned imports on this line. 

我想知道爲什麼而Maven插件也都儘管使用google_checks.xml事實報道他們的Eclipse插件並沒有強調這些問題。如何對齊它們?

回答

2

maven-checkstyle-plugin默認使用舊版本的Checkstyle。
https://maven.apache.org/plugins/maven-checkstyle-plugin/history.html(它列出6.11.2與maven-checkstyle-plugin版本2.17)

根據您所安裝的Eclipse的CS版本,你可以用2個不同版本的Checkstyle的運行作爲Eclipse的CS嘗試使用新版本,但可能不會使用最新的。
他們的網站狀態:

最新版本8.0.0,基於Checkstyle的8.0

要更改的Checkstyle maven-checkstyle-plugin使用的版本,請參閱https://maven.apache.org/plugins/maven-checkstyle-plugin/examples/upgrading-checkstyle.html