我正在尝试在项目中配置 Checkstyle。我已经添加:
apply plugin: 'checkstyle'
checkstyle {
// assign the latest checkstyle version explicitly
// default version is very old, likes 5.9
toolVersion = '8.6'
// checkstyle.xml copy from:
// https://raw.githubusercontent.com/checkstyle/checkstyle/checkstyle-8.6/src/main/resources/google_checks.xml
// the version should be as same as plugin version
configFile = rootProject.file('config/checkstyle/checkstyle.xml')
}
task Checkstyle(type: Checkstyle) {
source 'src/main/java'
include '**/*.java'
exclude '**/gen/**'
exclude '**/R.java'
exclude '**/BuildConfig.java'
// empty classpath
classpath = rootProject.files()
}
到我的根 gradle 文件allprojects
.
但当我跑步时./gradlew checkstyle
I get:
* What went wrong:
Execution failed for task ':app:Checkstyle'.
> Unable to create Root Module: config {/Users/user/Development/project/config/checkstyle/checkstyle.xml}, classpath {null}.
即使带有规则的文件也位于指定的目录中。
当我将 Android Gradle 插件更新到 3.3.0 时,发生了这种情况
请运行这个:
./gradlew checkstyle --stacktrace
可能您需要检查您的检查样式.xml配置文件。
我需要移动这两个标签:
<module name="SuppressionCommentFilter"/>
<!--Enable usage SUPPRESS CHECKSTYLE comment-->
<module name="SuppressWithNearbyCommentFilter">
<property name="commentFormat" value="CHECKSTYLE IGNORE"/>
<property name="checkFormat" value=".*"/>
<property name="influenceFormat" value="0"/>
</module>
inside
<module name="TreeWalker">
tag
我还需要删除:
<module name="SuppressionCommentFilter"/>
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)