2017-05-09 17 views
1

所以在這裏我casecheckstyle-suppressions.xml兩個checkstyle.xml和pom.xml中指定:定義鎮壓在checkstyle.xml過濾VS的pom.xml - Maven的插件的CheckStyle

checkstyle.xml:

<module name="SuppressionFilter"> 
     <property name="file" value="checkstyle-suppressions.xml"/> 
</module> 

的pom.xml

<project> 
    <reporting> 
    <plugins> 
     <plugin> 
      <groupId>org.apache.maven.plugins</groupId> 
      <artifactId>maven-checkstyle-plugin</artifactId> 
      <version>2.17</version> 
      <configuration> 
       <configLocation>checkstyle.xml</configLocation> 
       <suppressionsLocation>checkstyle-suppressions.xml</suppressionsLocation> 
      </configuration> 
      </plugin> 
     </plugins> 
     </reporting> 
    </project> 

我不是曲請確定是否需要在兩個文件中定義它,其中一個文件中包含SuppressionFilter模塊和<suppressionsLocation>標記。

我想用https://github.com/openmrs/openmrs-core/blob/master/checkstyle.xml與其他項目。然而在pom.xml與<configLocation>一套這樣做對https://github.com/openmrs/openmrs-core/blob/master/checkstyle.xml時,的CheckStyle,插件失敗,錯誤:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-checkstyle-plugin:2.17:check (validate) on project webservices.rest: Failed during checkstyle configuration: cannot initialize module SuppressionFilter - Cannot set property 'file' to 'checkstyle-suppressions.xml' in module SuppressionFilter: InvocationTargetException: Unable to find: checkstyle-suppressions.xml -> [Help 1] 
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-checkstyle-plugin:2.17:check (validate) on project webservices.rest: Failed during checkstyle configuration 

Caused by: org.apache.maven.plugin.MojoExecutionException: Failed during checkstyle configuration 

Caused by: com.puppycrawl.tools.checkstyle.api.CheckstyleException: cannot initialize module SuppressionFilter - Cannot set property 'file' to 'checkstyle-suppressions.xml' in module SuppressionFilter 

Caused by: com.puppycrawl.tools.checkstyle.api.CheckstyleException: Cannot set property 'file' to 'checkstyle-suppressions.xml' in module SuppressionFilter 

回答

0

I'm not quite sure whether there's the need to define it in both files

沒有必要。如果在POM中定義,maven會將其添加到幕後配置中。

Failed during checkstyle configuration
Unable to find: checkstyle-suppressions.xml

無法找到要加載的文件。
它試圖將文件作爲直接文件系統路徑(相對路徑應基於當前工作目錄),URL或資源在程序中找到。 http://checkstyle.sourceforge.net/config_filters.html#SuppressionFilter

相關問題