Error using checkstyle / google_checks.xml with maven-checkstyle-plugin

I am trying to use checkstyles google_checks.xml with maven-checkstyle-plugin . If I use google_checks.xml with the latest intelliJ checkstyle plugin, everything is correct, but when I try to configure it through the maven-checkstyle plugin, I get this error:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-checkstyle-plugin:2.13:check (default-cli) on project XX_XX_XX: Failed during checkstyle configuration: cannot initialize module TreeWalker - Unable to instantiate AvoidEscapedUnicodeCharacters: Unable to instantiate AvoidEscapedUnicodeCharactersCheck 

My pom.xml looks like this:

  <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <properties> [...] <checkstyle.file.path>develop/checkstyle/google_checks.xml</checkstyle.file.path> </properties> [...] <build> <plugins> [...] <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-checkstyle-plugin</artifactId> <version>2.13</version> <configuration> <configLocation>${checkstyle.file.path}</configLocation> <failOnViolation>false</failOnViolation> </configuration> </plugin> </plugins> </build> <reporting> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-checkstyle-plugin</artifactId> <version>2.9.1</version> <configuration> <configLocation>${checkstyle.file.path}</configLocation> <failOnViolation>false</failOnViolation> </configuration> </plugin> </plugins> </reporting> 

Do you have any suggestions on what might be wrong?

+6
source share
3 answers

This is fixed by updating the checkstyle dependency manually to the latest stable version :

  <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-checkstyle-plugin</artifactId> <version>2.13</version> <dependencies> <dependency> <groupId>com.puppycrawl.tools</groupId> <artifactId>checkstyle</artifactId> <version>${checkstyle.latest.version}</version> </dependency> </dependencies> <configuration> <configLocation>${checkstyle.file.path}</configLocation> <failOnViolation>false</failOnViolation> </configuration> </plugin> 
+13
source

Maven checkstyle plugin uses checkstyle 5.7 (the first line of the plugin description).

Checkstyle 5.7 does not have this check (see checking the package for grepcode).

You need to either disable this check or wait for the official MCHECKSTYLE-261 fix.

+4
source

I give a demo on

https://github.com/favoorr/Maven-Checkstyle-Multimodule-Use

Multiple Modules and Use Google Chechstyle

0
source

Source: https://habr.com/ru/post/979250/


All Articles