Thanks for the response. My case is we have several teams working on different Android projects. Some of them define lintOptions in build.gradle but some do not. For those with lintOptions defined in build.gradle, they might ignore something which we might have concern. We use Jenkins do perform the build continuously. I am thinking if it is possible to have something in init.gradle to override the definition for lintOptions in each of build.gradle file. I tried to write something as the following in init.gradle to re-configure lintOptions in the afterProject callback. It seems to work but I am not sure if this is good or if there is another way to achieve this.
gradle.afterProject { project ->
gradle.println("gradle.afterProject for the project: ${
project.name}")
if (project.pluginManager.hasPlugin('com.android.application')
|| project.pluginManager.hasPlugin('com.android.library')
|| project.pluginManager.hasPlugin('com.android.test')
|| project.pluginManager.hasPlugin('com.android.feature') ) {
gradle.println("The Android plugin is applied in the project ${
project.name}.")
gradle.println("Restore android.lintOptions to default values for the project ${
project.name} and set them as what we want in common.")
lintOptions {
abortOnError false // Keep going even we have errors.
absolutePaths true
check.clear()
checkAllWarnings false
checkReleaseBuilds true
disable.clear()
enable.clear()
explainIssues true
if (htmlOutput != null) {
htmlOutput file("${project.projectDir.absolutePath}/build/reports/lint-results.html")
}
htmlReport true
ignoreWarnings false
if (lintConfig != null) {
lintConfig file("${project.projectDir.absolutePath}/lint.xml")
}
noLines false
quiet false
if (severityOverrides != null ) {
severityOverrides.each { key, value ->
enable(key)
}
}
showAll false
if (textOutput != null) {
textOutput 'stdout'
}
textReport false
warningsAsErrors false
if (xmlOutput != null) {
xmlOutput file("${project.projectDir.absolutePath}/build/reports/lint-results.xml")
}
xmlReport true
}
}
}
}
Thanks a lot!
Ming-Ta
Ming-Ta Yu於 2018年2月14日星期三 UTC+8下午10時44分54秒寫道: