首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >将checkstyle/google_checks.xml与maven-checkstyle-plugin一起使用时出错

将checkstyle/google_checks.xml与maven-checkstyle-plugin一起使用时出错
EN

Stack Overflow用户
提问于 2014-12-08 01:05:21
回答 3查看 10K关注 0票数 10

我正在尝试将checkstyles google_checks.xmlmaven-checkstyle-plugin一起使用。如果我将google_checks.xml与最新的检查式intelliJ插件一起使用,一切都是正确的,但是当我尝试通过maven-checkstyle插件配置它时,我得到了这个错误:

代码语言:javascript
复制
[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看起来像这样:

代码语言:javascript
复制
   <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>

你们对可能出错的地方有什么建议吗?

EN

回答 3

Stack Overflow用户

回答已采纳

发布于 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>

票数 22
EN

Stack Overflow用户

发布于 2014-12-08 02:19:58

Maven checkstyle plugin使用checkstyle 5.7 (插件描述的第一行)。

Checkstyle 5.7没有这个检查(参见grepcode上的checks package )。

您需要禁用此检查或等待MCHECKSTYLE-261的官方修复。

票数 4
EN

Stack Overflow用户

发布于 2014-12-25 13:54:00

我在网上做了一个演示

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

多模块和使用Google Chechstyle

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/27345241

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档