【发布时间】:2019-01-21 06:44:45
【问题描述】:
我有一个包含多个库的 android 项目。我想对所有源代码运行 checkstyle 任务。项目结构:
app (com.android.application),
lib1 (com.android.library),
lib2 (com.android.library),
...
我遵循了这个配置教程:
https://github.com/Piasy/AndroidCodeQualityConfig
项目的 build.gradle:
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.4'
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
subprojects {
apply from: "$rootProject.projectDir/quality.gradle"
afterEvaluate {
check.dependsOn 'checkstyle'
}
}
quality.gradle:
apply plugin: 'checkstyle'
checkstyle {
toolVersion '7.4'
configFile file("${project.rootDir}/checkstyle/checkstyle.xml")
configProperties.checkstyleSuppressionFilterPath = file(
"${project.rootDir}/checkstyle/suppressions.xml")
.absolutePath
}
task checkstyle(type: Checkstyle, group: 'verification') {
source 'src'
include '**/*.java'
exclude '**/gen/**'
exclude '**/test/**'
exclude '**/androidTest/**'
exclude '**/R.java'
exclude '**/BuildConfig.java'
classpath = files()
}
如果我对根项目运行 gradle 检查,它只会在 :app 模块上运行,而不是整个项目。
我错过了什么?谢谢。
【问题讨论】:
标签: android module android-gradle-plugin checkstyle