Java google checkstyle Maven [英] Java google checkstyle Maven

查看:121
本文介绍了Java google checkstyle Maven的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用以下配置将我的Maven项目配置为使用google java check样式:

I'm trying to configure my Maven project to use google java check style with the following configuration:

google_checks.xml: https://github.com/checkstyle/checkstyle/blob/master/src/main/resources /google_checks.xml

google_checks.xml: https://github.com/checkstyle/checkstyle/blob/master/src/main/resources/google_checks.xml

pom.xml

<build>
  <plugins>
    <plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-checkstyle-plugin</artifactId>
      <version>2.17</version>
      <executions>
        <execution>
          <id>checkstyle</id>
          <phase>validate</phase>
          <goals>
            <goal>check</goal>
          </goals>
        </execution>
      </executions>
      <configuration>
        <configLocation>google_checks.xml</configLocation>
        <encoding>UTF-8</encoding>
        <consoleOutput>true</consoleOutput>
        <failsOnError>true</failsOnError>
      </configuration>
    </plugin>
  </plugins>
</build>

<reporting>
  <plugins>
    <plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-jxr-plugin</artifactId>
      <version>2.5</version>
    </plugin>
    <plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-checkstyle-plugin</artifactId>
      <version>2.17</version>
      <configuration>
        <configLocation>google_checks.xml</configLocation>
        <failOnViolation>false</failOnViolation>
        <enableFilesSummary>false</enableFilesSummary>
      </configuration>
    </plugin>
  </plugins>
</reporting>

似乎运行 mvn checkstyle:check 一开始很好。但经过几次运行后,我开始收到以下错误:

It seems to run mvn checkstyle:check fine at first. But after a few runs I start getting the following error:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-checkstyle-plugin:2.17:check 
(default-cli) on project PROJECT: Failed during checkstyle configuration: cannot initialize 
module TreeWalker - Token "METHOD_REF" was not found in Acceptable tokens list in check 
com.puppycrawl.tools.checkstyle.checks.whitespace.SeparatorWrapCheck -> [Help 1]

这是什么意思?为什么它只发生一些时间,如何摆脱它?

What does that mean? Why does it only happen some times and how do I get rid of it?

推荐答案


Token在检查
com.puppycrawl.tools.checkstyle.checks.whitespace.SeparatorWrapCheck

Token "METHOD_REF" was not found in Acceptable tokens list in check com.puppycrawl.tools.checkstyle.checks.whitespace.SeparatorWrapCheck



您正在尝试使用旧版Checkstyle的较新配置。

You are trying to use a newer configuration with an old version of Checkstyle.

https://github.com/checkstyle/checkstyle/blob/master/src/main/resources/google_checks.xml 中,这取决于checkstyle的快照版本。

The configuration at https://github.com/checkstyle/checkstyle/blob/master/src/main/resources/google_checks.xml is in master which is dependent on the snapshot version of checkstyle.

如果您使用谷歌配置而不做任何修改,你需要使用checkstyle中嵌入的那个。请参阅 https://stackoverflow.com/a/35486365/1016482

If you are using google configuration without any modifications, you need to use the one that comes embedded in checkstyle. See https://stackoverflow.com/a/35486365/1016482

否则,您可以集成更新版本的checkstyle以使用maven。请参阅 https://stackoverflow.com/a/27359107/1016482

Otherwise you can integrate a newer version of checkstyle to work with maven. See https://stackoverflow.com/a/27359107/1016482

这篇关于Java google checkstyle Maven的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆