Skip to content

Android: Add failOnWarnings check to android build.gradle and configure lint as warnings as error #12040

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
20 changes: 20 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -23,6 +23,26 @@ subprojects {
group = "io.grpc"
version = "1.73.0-SNAPSHOT" // CURRENT_GRPC_VERSION

plugins.withId("com.android.base") {
android {
lint {
abortOnError true
if (rootProject.hasProperty('failOnWarnings') && rootProject.failOnWarnings.toBoolean()) {
warningsAsErrors true
}
}
}
}

tasks.withType(JavaCompile).configureEach {
it.options.compilerArgs += [
"-Xlint:all"
]
if (rootProject.hasProperty('failOnWarnings') && rootProject.failOnWarnings.toBoolean()) {
it.options.compilerArgs += ["-Werror"]
}
}

repositories {
maven { // The google mirror is less flaky than mavenCentral()
url "https://maven-central.storage-download.googleapis.com/maven2/"