Stop using warnings as errors
Historically, we used this to make sure we don't have any warnings
sneak into the codebase, but we did not want to force developers from
complying to it locally, so it was default off, but enabled in CI.
Since then, we have added -Pandroidx.validateNoUnrecognizedMessages=true
that can catch any new warnings in output without turning on warnings
into errors. Since having a difference between CI and local is causing
remote cache misses (compiler arguments are different), and we can still
catch these warnings through output validation, this change removes the
use of warnings as errors.
Test: ./gradlew tasks
Change-Id: Ib3250c944c2e5412f004bf193fe02b93cb2b2731
diff --git a/buildSrc/private/src/main/kotlin/androidx/build/AndroidXGradleProperties.kt b/buildSrc/private/src/main/kotlin/androidx/build/AndroidXGradleProperties.kt
index 55e0c22..bad469c 100644
--- a/buildSrc/private/src/main/kotlin/androidx/build/AndroidXGradleProperties.kt
+++ b/buildSrc/private/src/main/kotlin/androidx/build/AndroidXGradleProperties.kt
@@ -33,11 +33,6 @@
const val DISPLAY_TEST_OUTPUT = "androidx.displayTestOutput"
/**
- * Setting this property turns javac and kotlinc warnings into errors that fail the build.
- */
-const val ALL_WARNINGS_AS_ERRORS = "androidx.allWarningsAsErrors"
-
-/**
* Setting this property changes "url" property in publishing maven artifact metadata
*/
const val ALTERNATIVE_PROJECT_URL = "androidx.alternativeProjectUrl"
@@ -152,7 +147,6 @@
const val KMP_ENABLE_NATIVE = "androidx.kmp.native.enabled"
val ALL_ANDROIDX_PROPERTIES = setOf(
- ALL_WARNINGS_AS_ERRORS,
ALTERNATIVE_PROJECT_URL,
VERSION_EXTRA_CHECK_ENABLED,
VALIDATE_PROJECT_STRUCTURE,
diff --git a/buildSrc/private/src/main/kotlin/androidx/build/AndroidXImplPlugin.kt b/buildSrc/private/src/main/kotlin/androidx/build/AndroidXImplPlugin.kt
index 8726fca..13242bf 100644
--- a/buildSrc/private/src/main/kotlin/androidx/build/AndroidXImplPlugin.kt
+++ b/buildSrc/private/src/main/kotlin/androidx/build/AndroidXImplPlugin.kt
@@ -263,7 +263,9 @@
) {
project.tasks.withType(KotlinCompile::class.java).configureEach { task ->
task.kotlinOptions.jvmTarget = "1.8"
- project.configureJavaCompilationWarnings(task)
+ task.kotlinOptions.freeCompilerArgs += listOf(
+ "-Xskip-metadata-version-check"
+ )
}
project.afterEvaluate {
val isAndroidProject = project.plugins.hasPlugin(LibraryPlugin::class.java) ||
@@ -929,32 +931,18 @@
private fun Project.configureJavaCompilationWarnings(androidXExtension: AndroidXExtension) {
afterEvaluate {
project.tasks.withType(JavaCompile::class.java).configureEach { task ->
- if (hasProperty(ALL_WARNINGS_AS_ERRORS)) {
- // If we're running a hypothetical test build confirming that tip-of-tree versions
- // are compatible, then we're not concerned about warnings
- if (!project.usingMaxDepVersions()) {
- task.options.compilerArgs.add("-Werror")
- task.options.compilerArgs.add("-Xlint:unchecked")
- if (androidXExtension.failOnDeprecationWarnings) {
- task.options.compilerArgs.add("-Xlint:deprecation")
- }
+ // If we're running a hypothetical test build confirming that tip-of-tree versions
+ // are compatible, then we're not concerned about warnings
+ if (!project.usingMaxDepVersions()) {
+ task.options.compilerArgs.add("-Xlint:unchecked")
+ if (androidXExtension.failOnDeprecationWarnings) {
+ task.options.compilerArgs.add("-Xlint:deprecation")
}
}
}
}
}
-private fun Project.configureJavaCompilationWarnings(task: KotlinCompile) {
- if (hasProperty(ALL_WARNINGS_AS_ERRORS) &&
- !project.usingMaxDepVersions()
- ) {
- task.kotlinOptions.allWarningsAsErrors = true
- }
- task.kotlinOptions.freeCompilerArgs += listOf(
- "-Xskip-metadata-version-check"
- )
-}
-
/**
* Guarantees unique names for the APKs, and modifies some of the suffixes. The APK name is used
* to determine what gets run by our test runner
diff --git a/busytown/androidx-studio-integration-host-tests.sh b/busytown/androidx-studio-integration-host-tests.sh
index 439ed55..34d4f02 100755
--- a/busytown/androidx-studio-integration-host-tests.sh
+++ b/busytown/androidx-studio-integration-host-tests.sh
@@ -6,6 +6,7 @@
SCRIPT_PATH="$(cd $(dirname $0) && pwd)"
$SCRIPT_PATH/impl/build-studio-and-androidx.sh test \
+ --ci \
-Pandroidx.ignoreTestFailures \
-Pandroidx.displayTestOutput=false \
"$@"
diff --git a/busytown/androidx-studio-integration-lint.sh b/busytown/androidx-studio-integration-lint.sh
index 1ebe930..80d7657 100755
--- a/busytown/androidx-studio-integration-lint.sh
+++ b/busytown/androidx-studio-integration-lint.sh
@@ -2,11 +2,7 @@
SCRIPT_PATH="$(cd $(dirname $0) && pwd)"
$SCRIPT_PATH/impl/build-studio-and-androidx.sh \
- -Pandroidx.allWarningsAsErrors \
- -Pandroidx.summarizeStderr \
- -Pandroidx.verifyUpToDate \
+ --ci \
-x verifyDependencyVersions \
lintAnalyze \
- lintAnalyzeDebug \
- --no-daemon \
- --stacktrace
+ lintAnalyzeDebug
diff --git a/busytown/androidx-studio-integration-vitals.sh b/busytown/androidx-studio-integration-vitals.sh
index f5d893c..f96ca2f 100755
--- a/busytown/androidx-studio-integration-vitals.sh
+++ b/busytown/androidx-studio-integration-vitals.sh
@@ -2,7 +2,8 @@
SCRIPT_PATH="$(cd $(dirname $0) && pwd)"
"$SCRIPT_PATH"/impl/build-studio-and-androidx.sh \
- -Pandroidx.allWarningsAsErrors \
+ -Pandroidx.summarizeStderr \
tasks \
:navigation:navigation-safe-args-gradle-plugin:test \
- --stacktrace
+ --stacktrace \
+ --no-daemon
diff --git a/busytown/androidx-studio-integration.sh b/busytown/androidx-studio-integration.sh
index 27a2179..0165dd4 100755
--- a/busytown/androidx-studio-integration.sh
+++ b/busytown/androidx-studio-integration.sh
@@ -4,12 +4,9 @@
# Exclude lint tasks, as those are covered by the
# androidx-studio-integration-lint.sh script
$SCRIPT_PATH/impl/build-studio-and-androidx.sh \
- -Pandroidx.allWarningsAsErrors \
- -Pandroidx.verifyUpToDate \
-x lint \
-x lintDebug \
-x lintReport \
-x verifyDependencyVersions \
listTaskOutputs \
- bOS \
- --stacktrace
+ bOS
diff --git a/busytown/androidx_with_metalava.sh b/busytown/androidx_with_metalava.sh
index 1c4435b..156fc64 100755
--- a/busytown/androidx_with_metalava.sh
+++ b/busytown/androidx_with_metalava.sh
@@ -3,8 +3,5 @@
SCRIPT_PATH="$(cd $(dirname $0) && pwd)"
$SCRIPT_PATH/impl/build-metalava-and-androidx.sh \
- -Pandroidx.allWarningsAsErrors \
- -Pandroidx.verifyUpToDate \
listTaskOutputs \
- checkApi \
- --stacktrace
+ checkApi
diff --git a/busytown/impl/build-metalava-and-androidx.sh b/busytown/impl/build-metalava-and-androidx.sh
index 2fb33a6..f4e3e20 100755
--- a/busytown/impl/build-metalava-and-androidx.sh
+++ b/busytown/impl/build-metalava-and-androidx.sh
@@ -57,8 +57,7 @@
function buildAndroidx() {
LOG_PROCESSOR="$SCRIPTS_DIR/../development/build_log_processor.sh"
- properties="-Pandroidx.summarizeStderr --no-daemon"
- "$LOG_PROCESSOR" $gw $properties -p frameworks/support $androidxArguments \
+ "$LOG_PROCESSOR" $gw --ci -p frameworks/support $androidxArguments \
--dependency-verification=off # building against tip of tree of metalava that potentially pulls in new dependencies
}
diff --git a/busytown/impl/build-studio-and-androidx.sh b/busytown/impl/build-studio-and-androidx.sh
index 7e0baca..3c2ba55 100755
--- a/busytown/impl/build-studio-and-androidx.sh
+++ b/busytown/impl/build-studio-and-androidx.sh
@@ -99,9 +99,8 @@
function buildAndroidx() {
RETURN_CODE=0
LOG_PROCESSOR="$SCRIPTS_DIR/../development/build_log_processor.sh"
- properties="-Pandroidx.summarizeStderr --no-daemon"
# Remove -Pandroid.overrideVersionCheck=true once b/233766756 is fixed
- if "$LOG_PROCESSOR" frameworks/support/gradlew $properties -p frameworks/support $androidxArguments --profile \
+ if "$LOG_PROCESSOR" frameworks/support/gradlew -p frameworks/support $androidxArguments --profile \
-Pandroid.overrideVersionCheck=true \
--dependency-verification=off; then # building against tip of tree of AGP that potentially pulls in new dependencies
echo build passed
diff --git a/gradlew b/gradlew
index 951f96b..073dc18 100755
--- a/gradlew
+++ b/gradlew
@@ -267,8 +267,7 @@
fi
fi
if [ "$compact" == "--strict" ]; then
- expanded="-Pandroidx.allWarningsAsErrors\
- -Pandroidx.validateNoUnrecognizedMessages\
+ expanded="-Pandroidx.validateNoUnrecognizedMessages\
-Pandroidx.verifyUpToDate\
--no-watch-fs\
--no-daemon"