我正在尝试将checkstyles google_checks.xml与maven-checkstyle-plugin一起使用。如果我使用带有最新checkstyle intelliJ插件的google_checks.xml,一切都是正确的,但是当我尝试通过maven-checkstyle插件进行配置时,我收到此错误:
[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
我的pom.xml看起来像这样:
<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>
你们有什么可能出错的建议吗?
答案 0 :(得分:22)
通过手动将checkstyle-dependency更新为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>
答案 1 :(得分:4)
Maven checkstyle plugin使用checkstyle 5.7(插件描述的第一行)。
Checkstyle 5.7没有此检查(请参阅grepcode上的checks package)。
您需要禁用此检查或等待MCHECKSTYLE-261的正式修复。
答案 2 :(得分:1)