-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
base: master
Are you sure you want to change the base?
Android: Add failOnWarnings check to android build.gradle and configure lint as warnings as error #12040
Changes from 2 commits
2bf4968
c571f77
dbfe6d4
148c017
f9a0fde
85a6ba6
94f92f6
6d3f981
4e81d10
b151cb0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,7 +20,15 @@ android { | |
versionName "1.0" | ||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" | ||
} | ||
lintOptions { abortOnError true } | ||
|
||
// fail on android lint warnings if failOnWarning is set true | ||
lintOptions { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If we are doing this anyway, lintOptions is deprecated. Use lint instead. (Wait for Eric's comment on this before working) |
||
abortOnError true | ||
if (rootProject.hasProperty("failOnWarnings") && rootProject.failOnWarnings.toBoolean()) { | ||
warningsAsErrors true | ||
} | ||
} | ||
|
||
publishing { | ||
singleVariant('release') { | ||
withSourcesJar() | ||
|
@@ -44,6 +52,14 @@ dependencies { | |
testImplementation libraries.truth | ||
} | ||
|
||
// Enforce -Werror on java compiler if failOnWarning is set | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You may remove the comments as they are self explanatory. |
||
tasks.withType(JavaCompile).configureEach { | ||
it.options.compilerArgs += ["-Xlint:all"] | ||
if (rootProject.hasProperty("failOnWarnings") && rootProject.failOnWarnings.toBoolean()) { | ||
it.options.compilerArgs += ["-Werror"] | ||
} | ||
} | ||
|
||
tasks.register("javadocs", Javadoc) { | ||
source = android.sourceSets.main.java.srcDirs | ||
classpath += files(android.getBootClasspath()) | ||
|
Uh oh!
There was an error while loading. Please reload this page.