2014-02-28 112 views
1

我正在使用Maven和Checkstyle來檢查我的代碼的質量。儘管我想在CheckStyle中關閉一些內容。更改Maven CheckStyle配置

有一個模塊負責尾隨空格。它給出的評論是:

Line has trailing spaces. 

現在我假設該模塊照顧這就是所謂的RegexpSingleline,我想關閉它。我已經嘗試通過取消./myproject/target/checkstyle-checker.xml中的文件註釋,但是當我運行mvn site時,此文件會自動再次生成,並且我的更改將消失。

我該如何關閉這個模糊?

回答

1

您應該複製checkstyle-checker.xml文檔並將其存儲在/target之外(因爲此目錄將在構建中被覆蓋!)。然後,在你pom.xml您可以指定的CheckStyle插件配置這個位置(見:http://maven.apache.org/plugins/maven-checkstyle-plugin/examples/custom-checker-config.html

<project> 
    ... 
    <reporting> 
    <plugins> 
     <plugin> 
     <groupId>org.apache.maven.plugins</groupId> 
     <artifactId>maven-checkstyle-plugin</artifactId> 
     <version>..your version of the plugin..</version> 
     <configuration> 
      <configLocation>..your location../checkstyle-checker.xml</configLocation> 
     </configuration> 
     </plugin> 
    </plugins> 
    </reporting> 
    ... 
</project> 
+0

非常感謝!這幫助我馬上! – Socrates