为了检查所有子项目的代码风格。我创建了一个文件checkstyle.gradle
并将其应用于根目录中的build.gradle
。
apply plugin: 'checkstyle'
subprojects { project ->
task checkstyle(type: Checkstyle) {
configFile rootProject.file('checkstyle.xml')
ignoreFailures false
showViolations true
classpath = files()
source 'src/main/java'
}
// check code style after project evaluation
afterEvaluate {
project.tasks.findByName('checkstyle').execute()
}
}
发生错误。
* 什么地方出了错: >配置项目':app'时出现问题。 >在任务':app:checkstyle'的配置中发现了一个问题。 >没有为属性'checkstyleClasspath'指定值。
我不知道为什么会发生错误。
我只知道如何解决这个错误。
subprojects { project ->
apply plugin: 'checkstyle'
task checkstyle(type: Checkstyle) {
description 'Runs Checkstyle inspection against ICanPlayer sourcesets.'
group = 'Code Quality'
configFile rootProject.file('checkstyle.xml')
ignoreFailures false
showViolations true
classpath = files()
source 'src/main/java'
}
// check code style after project evaluation
afterEvaluate {
check.dependsOn('checkstyle')
}
}