【问题标题】:error running mvn checkstyle:checkstyle错误运行 mvn checkstyle:checkstyle
【发布时间】:2012-09-08 03:31:24
【问题描述】:

执行命令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 兼容? (除了基于 checkstyle 文档的每条规则的概述规则)

【问题讨论】:

    标签: java maven plugins eclipse-plugin checkstyle


    【解决方案1】:

    我已经设法摆脱了修改规则 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>
    

    希望我能帮助遇到同样问题的人。问候。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-18
      • 2021-10-13
      • 2012-09-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多