在执行命令mvn checkstyle:checkstyle时,我得到了以下错误
An error has occurred in Checkstyle report generation.
...
Caused by: com.puppycrawl.tools.checkstyle.api.CheckstyleException: cannot initialize module TreeWalker - Unable to instantiate GenericIllegalRegexp
at com.puppycrawl.tools.checkstyle.Checker.setupChild(Checker.java:178)
at com.puppycrawl.tools.checkstyle.api.AutomaticBean.configure(AutomaticBean.java:184)
at org.apache.maven.plugin.checkstyle.DefaultCheckstyleExecutor.executeCheckstyle(DefaultCheckstyleExecutor.java:170)
at org.apache.maven.plugin.checkstyle.AbstractCheckstyleReport.executeReport(AbstractCheckstyleReport.java:259)
... 24 more
Caused by: com.puppycrawl.tools.checkstyle.api.CheckstyleException: Unable to instantiate GenericIllegalRegexp
at com.puppycrawl.tools.checkstyle.PackageObjectFactory.createModule(PackageObjectFactory.java:155)
at com.puppycrawl.tools.checkstyle.TreeWalker.setupChild(TreeWalker.java:161)
at com.puppycrawl.tools.checkstyle.api.AutomaticBean.configure(AutomaticBean.java:184)
at com.puppycrawl.tools.checkstyle.Checker.setupChild(Checker.java:157)
... 27 more
Caused by: com.puppycrawl.tools.checkstyle.api.CheckstyleException: Unable to instantiate GenericIllegalRegexpCheck
at com.puppycrawl.tools.checkstyle.PackageObjectFactory.doMakeObject(PackageObjectFactory.java:98)
at com.puppycrawl.tools.checkstyle.PackageObjectFactory.createModule(PackageObjectFactory.java:152)
... 30 more我猜这个错误与使用较旧版本的checkstyle创建的规则有关。
pom.xml中的checkstyle插件配置如下:
...
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>2.9.1</version>
<configuration>
<configLocation>checkstyle.xml</configLocation>
<headerLocation>LICENSE.txt</headerLocation>
</configuration>
</plugin>
...有没有一种方法或工具可以迁移规则,使其与checkstyle 5.5兼容?(不是根据检查样式文档查看每个规则的规则)
发布于 2012-09-15 20:07:49
我已经设法摆脱了修改规则的xml的那个特殊异常。
我已经替换了:
<module name="GenericIllegalRegexp">
<property name="format" value="\s+$"/>
<property name="message" value="Line has trailing spaces."/>
<property name="ignoreComments" value="true"/>
</module>使用
<module name="RegexpSinglelineJava">
<property name="format" value="\s+$"/>
<property name="message" value="Line has trailing spaces."/>
<property name="ignoreComments" value="true"/>
</module>希望我帮助了有同样问题的人。致以问候。
https://stackoverflow.com/questions/12433466
复制相似问题