我正在尝试将checkstyles google_checks.xml与maven-checkstyle-plugin一起使用。如果我将google_checks.xml与最新的检查式intelliJ插件一起使用,一切都是正确的,但是当我尝试通过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>
你们对可能出错的地方有什么建议吗?
发布于 2014-12-08 21:27:51
通过手动将checkstyle依赖项更新为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>
发布于 2014-12-08 02:19:58
Maven checkstyle plugin使用checkstyle 5.7 (插件描述的第一行)。
Checkstyle 5.7没有这个检查(参见grepcode上的checks package )。
您需要禁用此检查或等待MCHECKSTYLE-261的官方修复。
发布于 2014-12-25 13:54:00
https://stackoverflow.com/questions/27345241
复制相似问题