Bir*_*rei 10 checkstyle gradle
我使用Android Studio创建了一个Android项目.在build.gradle应用程序添加:
apply from: '../config/quality.gradle'
然后我config用两个文件创建目录:quality.gradle如:
apply plugin: 'checkstyle'
task checkstyle(type: Checkstyle) {
    configFile file("${project.rootDir}/config/checkstyle.xml")
    source 'src'
    include '**/*.java'
    exclude '**/gen/**'
    classpath = files()
}
并checkstyle.xml喜欢:
<?xml version="1.0"?>
<!DOCTYPE module PUBLIC
    "-//Puppy Crawl//DTD Check Configuration 1.3//EN"
    "http://www.puppycrawl.com/dtds/configuration_1_3.dtd">
<module name="Checker">
    <module name="TreeWalker">
        <module name="NeedBraces">
            <property name="tokens" value="LITERAL_CASE, LITERAL_DEFAULT"/>
            <property name="allowSingleLineStatement" value="true"/>
        </module>
    </module>
</module>
跑步gradle checkstyle给我以下错误:
Executing external task 'checkstyle'...
:app:checkstyle FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:checkstyle'.
> Unable to create a Checker: cannot initialize module TreeWalker - Property 'allowSingleLineStatement' in module NeedBraces does not exist, please check the documentation
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
如果我删除行:
<property name="allowSingleLineStatement" value="true"/>
有用.但阅读文档,第一版也应该有效.
它发生的类似于:
<module name="EmptyCatchBlock">
    <property name="exceptionVariableName" value="expected|ignore"/>
</module>
那扔我:
* What went wrong:
Execution failed for task ':app:checkstyle'.
> Unable to create a Checker: cannot initialize module TreeWalker - Unable to instantiate EmptyCatchBlock
我做错了什么或以什么方式错过理解文档?
bar*_*uin 18
在撰写本文时,Gradle 默认使用Checkstyle 5.9.该allowSingleLineStatement物业仅在Checkstyle 6.5中添加.所以,你应该能够通过使用更新的Checkstyle版本来实现这一点:
checkstyle {
    configFile = file("${project.rootDir}/config/checkstyle.xml")
    toolVersion = '6.7'
}
不幸的是,Checkstyle文档没有版本化,所以网站总是只有最新的文档,这使得很难找出这样的东西.
| 归档时间: | 
 | 
| 查看次数: | 6780 次 | 
| 最近记录: |