Java google checkstyle Maven

I am trying to configure my Maven project to use google java validation style with the following configuration:

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> 

It seems mvn checkstyle:check is being executed first fine. But after several starts, 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 it mean? Why does this happen only a few times and how can I get rid of it?

+5
source share
1 answer

Token "METHOD_REF" was not found in the list of Acceptable Tokens com.puppycrawl.tools.checkstyle.checks.whitespace.SeparatorWrapCheck

You are trying to use the new configuration with the old version of Checkstyle.

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

If you use the Google configuration without any changes, you need to use the one built into checkstyle. See fooobar.com/questions/967036 / ...

Otherwise, you can integrate a newer version of checkstyle to work with maven. See fooobar.com/questions/979250 / ...

+8
source

All Articles