如何在maven中配置checkstyle?

我正在使用Maven
我有一个父模块和一些其他模块。 他们看着像是:

家长
 ├──pom.xml
 ├──ModulA
 |  └──pom.xml
 └──ModulB
     ├──pom.xml
     └──文件夹
         └──checkstyle.xml

我试图用自己的规则替换规则。 但它忽略了我的规则。 我将插件添加到父pom.xml中

 org.apache.maven.plugins maven-checkstyle-plugin 2.9.1  true  ${basedir}/../ModulB/folder/checkstyle.xml    

哪里有问题?

编辑:


mvn checkstyle:checkstyle -X

 ...   ${checkstyle.config.location}  ${checkstyle.enable.files.summary} ${checkstyle.enable.rss} ${checkstyle.enable.rules.summary} ${checkstyle.enable.severity.summary} ${encoding} ${checkstyle.excludes}   ${basedir}/LICENSE.txt ${checkstyle.header.file}  ${checkstyle.includes} ${linkXRef}  ${checkstyle.output.file} ${checkstyle.output.format}  ${checkstyle.properties.location} ${checkstyle.skip}  ${checkstyle.suppression.expression} ${checkstyle.suppressions.location}    ... 

要获取自定义配置,您需要将文件声明为属性:

  ...     ...  org.apache.maven.plugins maven-checkstyle-plugin 2.9.1     

从我的教程中获取如何创建自定义CheckStyle检查:
http://blog.blundellapps.com/create-your-own-checkstyle-check/

源代码在这里:
https://github.com/blundell/CreateYourOwnCheckStyleCheck

为什么你不把checkstyle配置放在像src/main/resources这样的父项目的目录中,并在父pom.xml中像这样参数化插件

   org.apache.maven.plugins maven-checkstyle-plugin RELEASE  src/main/resources/checkstyle.xml   

子项目应该有访问权限执行此配置