私は次のような構成でGoogleのjavaチェックスタイルを使用するために私のMavenプロジェクトを設定しようとしている:JavaのグーグルのCheckstyleのMaven
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
を実行しているようです。しかし、いくつかの実行後、私は次のエラーが発生し始めます:
[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]
これはどういう意味ですか?なぜそれは何度かしか起こらないのですが、どうすればそれを取り除くことができますか?
https://maven.apache.org/plugins/maven-checkstyle-plugin/examples/upgrading-checkstyle.htmlに記載されているように、おそらく新しいバージョンのCheckstyleを設定する必要があります。 maven-checkstyle-pluginはデフォルトでバージョン6.11.2を使用していますが、Googleのチェックではすべてのルールが使用されていない可能性があります。 –