我该如何在Android应用程序和Java模块上同时运行gradlew lintDebug
?
以下是示例项目设置:
root-project
|- android-app
|- java-library
这是我到目前为止所做的:
gradle.taskGraph.whenReady { taskGraph ->
if (taskGraph.hasTask(":$project.name:lintDebug")) {
rootProject.subprojects.each { subprojects ->
// Do not add the same sources twice for this project
if (subprojects.name == project.name) {
return
}
// Append other modules source directories to this one
android.sourceSets.main.java.srcDirs += subprojects.files("./src/main/java")
}
}
}
将此代码片段添加到
android-app
模块中,可以使您运行gradlew:android-app:lintDebug
来在两个模块的源文件上运行lint。