Start enforcing javac warnings.

- Add new ways to ignore warnings for modules with warnings
- Enable -Xlint:deprecation and -Xlint:unchecked by default to
  prevent regressions.

Test: ./gradlew assembleDebug
Change-Id: I95f73afde042a2d61984f59ee3d3350a013c0044
diff --git a/buildSrc/src/main/kotlin/androidx/build/SupportAndroidLibraryPlugin.kt b/buildSrc/src/main/kotlin/androidx/build/SupportAndroidLibraryPlugin.kt
index dd2e6da..e3458a5 100644
--- a/buildSrc/src/main/kotlin/androidx/build/SupportAndroidLibraryPlugin.kt
+++ b/buildSrc/src/main/kotlin/androidx/build/SupportAndroidLibraryPlugin.kt
@@ -65,6 +65,20 @@
 
             VersionFileWriterTask.setUpAndroidLibrary(project, library)
             DiffAndDocs.registerAndroidProject(project, library, supportLibraryExtension)
+
+            library.libraryVariants.all { libraryVariant ->
+                if (libraryVariant.getBuildType().getName().equals("debug")) {
+                    @Suppress("DEPRECATION")
+                    val javaCompile = libraryVariant.javaCompile
+                    if (supportLibraryExtension.failOnUncheckedWarnings) {
+                        javaCompile.options.compilerArgs.add("-Xlint:unchecked")
+                    }
+                    if (supportLibraryExtension.failOnDeprecationWarnings) {
+                        javaCompile.options.compilerArgs.add("-Xlint:deprecation")
+                    }
+                    javaCompile.options.compilerArgs.add("-Werror")
+                }
+            }
         }
 
         project.apply(mapOf("plugin" to "com.android.library"))
diff --git a/buildSrc/src/main/kotlin/androidx/build/SupportLibraryExtension.kt b/buildSrc/src/main/kotlin/androidx/build/SupportLibraryExtension.kt
index 4f69460..98528bb 100644
--- a/buildSrc/src/main/kotlin/androidx/build/SupportLibraryExtension.kt
+++ b/buildSrc/src/main/kotlin/androidx/build/SupportLibraryExtension.kt
@@ -34,6 +34,9 @@
     private var licenses: MutableCollection<License> = ArrayList()
     var java8Library = false
     var publish = false
+    var failOnUncheckedWarnings = true
+    var failOnDeprecationWarnings = true
+
     /**
      * This flag works only if publish flag is "true".
      * It is useful for modules that are used for tooling. For example room annotation
diff --git a/car/build.gradle b/car/build.gradle
index 52d2a40..e53471b 100644
--- a/car/build.gradle
+++ b/car/build.gradle
@@ -54,4 +54,5 @@
     description = "Android Car Support UI"
     java8Library = true
     minSdkVersion = 24
+    failOnUncheckedWarnings = false
 }
diff --git a/cardview/build.gradle b/cardview/build.gradle
index d583284..c950dac 100644
--- a/cardview/build.gradle
+++ b/cardview/build.gradle
@@ -22,4 +22,5 @@
     mavenGroup = LibraryGroups.CARDVIEW
     inceptionYear = "2011"
     description = "Android Support CardView v7"
+    failOnDeprecationWarnings = false
 }
diff --git a/compat/build.gradle b/compat/build.gradle
index 940819b..e4a719a 100644
--- a/compat/build.gradle
+++ b/compat/build.gradle
@@ -37,4 +37,6 @@
     mavenGroup = LibraryGroups.CORE
     inceptionYear = "2015"
     description = "The Support Library is a static library that you can add to your Android application in order to use APIs that are either not available for older platform versions or utility APIs that aren\'t a part of the framework APIs. Compatible on devices running API 14 or later."
+    failOnUncheckedWarnings = false
+    failOnDeprecationWarnings = false
 }
diff --git a/content/build.gradle b/content/build.gradle
index 25b01e5f..d5f8b80 100644
--- a/content/build.gradle
+++ b/content/build.gradle
@@ -38,4 +38,5 @@
     mavenGroup = LibraryGroups.CONTENTPAGING
     inceptionYear = "2017"
     description = "Library providing support for paging across content exposed via a ContentProvider. Use of this library allows a client to avoid expensive interprocess \"cursor window swaps\" on the UI thread."
+    failOnDeprecationWarnings = false
 }
diff --git a/coordinatorlayout/build.gradle b/coordinatorlayout/build.gradle
index 8e72580..4775f67 100644
--- a/coordinatorlayout/build.gradle
+++ b/coordinatorlayout/build.gradle
@@ -39,4 +39,6 @@
     mavenGroup = LibraryGroups.COORDINATORLAYOUT
     inceptionYear = "2011"
     description = "The Support Library is a static library that you can add to your Android application in order to use APIs that are either not available for older platform versions or utility APIs that aren't a part of the framework APIs. Compatible on devices running API 14 or later."
+    failOnUncheckedWarnings = false
+    failOnDeprecationWarnings = false
 }
diff --git a/cursoradapter/build.gradle b/cursoradapter/build.gradle
index ce80655..2493a2b 100644
--- a/cursoradapter/build.gradle
+++ b/cursoradapter/build.gradle
@@ -16,4 +16,5 @@
     mavenGroup = LibraryGroups.CURSORADAPTER
     inceptionYear = "2018"
     description = "The Support Library is a static library that you can add to your Android application in order to use APIs that are either not available for older platform versions or utility APIs that aren't a part of the framework APIs. Compatible on devices running API 14 or later."
+    failOnDeprecationWarnings = false
 }
diff --git a/customview/build.gradle b/customview/build.gradle
index 37cfc2f..f2ebd43 100644
--- a/customview/build.gradle
+++ b/customview/build.gradle
@@ -22,4 +22,5 @@
     mavenGroup = LibraryGroups.CUSTOMVIEW
     inceptionYear = "2018"
     description = "The Support Library is a static library that you can add to your Android application in order to use APIs that are either not available for older platform versions or utility APIs that aren't a part of the framework APIs. Compatible on devices running API 14 or later."
+    failOnDeprecationWarnings = false
 }
diff --git a/dynamic-animation/build.gradle b/dynamic-animation/build.gradle
index 637abb4d..6da13e0 100644
--- a/dynamic-animation/build.gradle
+++ b/dynamic-animation/build.gradle
@@ -24,4 +24,5 @@
     mavenGroup = LibraryGroups.DYNAMICANIMATION
     inceptionYear = "2017"
     description = "Physics-based animation in support library, where the animations are driven by physics force. You can use this Animation library to create smooth and realistic animations."
+    failOnUncheckedWarnings = false
 }
\ No newline at end of file
diff --git a/fragment/build.gradle b/fragment/build.gradle
index 5f8954f..7faa903 100644
--- a/fragment/build.gradle
+++ b/fragment/build.gradle
@@ -30,4 +30,6 @@
     mavenGroup = LibraryGroups.FRAGMENT
     inceptionYear = "2011"
     description = "The Support Library is a static library that you can add to your Android application in order to use APIs that are either not available for older platform versions or utility APIs that aren\'t a part of the framework APIs. Compatible on devices running API 14 or later."
+    failOnUncheckedWarnings = false
+    failOnDeprecationWarnings = false
 }
diff --git a/graphics/drawable/static/build.gradle b/graphics/drawable/static/build.gradle
index 19a03665..423cb22 100644
--- a/graphics/drawable/static/build.gradle
+++ b/graphics/drawable/static/build.gradle
@@ -31,4 +31,5 @@
     mavenGroup = LibraryGroups.VECTORDRAWABLE
     inceptionYear = "2015"
     description = "Android Support VectorDrawable"
+    failOnDeprecationWarnings = false
 }
\ No newline at end of file
diff --git a/gridlayout/build.gradle b/gridlayout/build.gradle
index fb4dd10..930e191 100644
--- a/gridlayout/build.gradle
+++ b/gridlayout/build.gradle
@@ -21,4 +21,5 @@
     mavenGroup = LibraryGroups.GRIDLAYOUT
     inceptionYear = "2013"
     description = "Android Support Grid Layout"
+    failOnDeprecationWarnings = false
 }
diff --git a/leanback-preference/build.gradle b/leanback-preference/build.gradle
index a6e0d272..4f49bef 100644
--- a/leanback-preference/build.gradle
+++ b/leanback-preference/build.gradle
@@ -30,4 +30,5 @@
     inceptionYear = "2015"
     description = "Android Support Leanback Preference v17"
     minSdkVersion = 17
+    failOnDeprecationWarnings = false
 }
\ No newline at end of file
diff --git a/leanback/build.gradle b/leanback/build.gradle
index 56b7fc5..a1e468b 100644
--- a/leanback/build.gradle
+++ b/leanback/build.gradle
@@ -37,4 +37,6 @@
     inceptionYear = "2014"
     description = "Android Support Leanback v17"
     minSdkVersion = 17
+    failOnUncheckedWarnings = false
+    failOnDeprecationWarnings = false
 }
diff --git a/legacy/v13/build.gradle b/legacy/v13/build.gradle
index d8ef8f7..c881632 100644
--- a/legacy/v13/build.gradle
+++ b/legacy/v13/build.gradle
@@ -16,4 +16,5 @@
     mavenGroup = LibraryGroups.LEGACY
     inceptionYear = "2011"
     description = "The Support Library is a static library that you can add to your Android application in order to use APIs that are either not available for older platform versions or utility APIs that aren't a part of the framework APIs. Compatible on devices running API 14 or later."
+    failOnDeprecationWarnings = false
 }
diff --git a/lifecycle/extensions/build.gradle b/lifecycle/extensions/build.gradle
index a2be25d..14a974c 100644
--- a/lifecycle/extensions/build.gradle
+++ b/lifecycle/extensions/build.gradle
@@ -55,4 +55,5 @@
     inceptionYear = "2017"
     description = "Android Lifecycle Extensions"
     url = SupportLibraryExtension.ARCHITECTURE_URL
+    failOnDeprecationWarnings = false
 }
diff --git a/lifecycle/livedata-core/build.gradle b/lifecycle/livedata-core/build.gradle
index 76f6c83..e9e1cfd 100644
--- a/lifecycle/livedata-core/build.gradle
+++ b/lifecycle/livedata-core/build.gradle
@@ -42,4 +42,5 @@
     inceptionYear = "2017"
     description = "Android Lifecycle LiveData Core"
     url = SupportLibraryExtension.ARCHITECTURE_URL
+    failOnUncheckedWarnings = false
 }
diff --git a/lifecycle/runtime/build.gradle b/lifecycle/runtime/build.gradle
index baa2b32..40b250c 100644
--- a/lifecycle/runtime/build.gradle
+++ b/lifecycle/runtime/build.gradle
@@ -34,4 +34,5 @@
     inceptionYear '2017'
     description "Android Lifecycle Runtime"
     url SupportLibraryExtension.ARCHITECTURE_URL
+    failOnDeprecationWarnings = false
 }
\ No newline at end of file
diff --git a/lifecycle/viewmodel/build.gradle b/lifecycle/viewmodel/build.gradle
index 1494733..cc71b39 100644
--- a/lifecycle/viewmodel/build.gradle
+++ b/lifecycle/viewmodel/build.gradle
@@ -44,4 +44,5 @@
     inceptionYear = "2017"
     description = "Android Lifecycle ViewModel"
     url = SupportLibraryExtension.ARCHITECTURE_URL
+    failOnUncheckedWarnings = false
 }
\ No newline at end of file
diff --git a/loader/build.gradle b/loader/build.gradle
index 8c99ea5..9a34ff2 100644
--- a/loader/build.gradle
+++ b/loader/build.gradle
@@ -25,4 +25,5 @@
     mavenGroup = LibraryGroups.LOADER
     inceptionYear = "2011"
     description = "The Support Library is a static library that you can add to your Android application in order to use APIs that are either not available for older platform versions or utility APIs that aren\'t a part of the framework APIs. Compatible on devices running API 14 or later."
+    failOnUncheckedWarnings = false
 }
diff --git a/media/build.gradle b/media/build.gradle
index eda587d..af0928b4 100644
--- a/media/build.gradle
+++ b/media/build.gradle
@@ -41,4 +41,6 @@
     mavenGroup = LibraryGroups.MEDIA
     inceptionYear = "2011"
     description = "The Support Library is a static library that you can add to your Android application in order to use APIs that are either not available for older platform versions or utility APIs that aren't a part of the framework APIs. Compatible on devices running API 14 or later."
+    failOnUncheckedWarnings = false
+    failOnDeprecationWarnings = false
 }
diff --git a/media/version-compat-tests/lib/build.gradle b/media/version-compat-tests/lib/build.gradle
index df9e75c..f9dfeac 100644
--- a/media/version-compat-tests/lib/build.gradle
+++ b/media/version-compat-tests/lib/build.gradle
@@ -23,3 +23,7 @@
 dependencies {
     implementation(JUNIT)
 }
+
+supportLibrary {
+    failOnUncheckedWarnings = false
+}
\ No newline at end of file
diff --git a/mediarouter/build.gradle b/mediarouter/build.gradle
index a2463a4..20442420 100644
--- a/mediarouter/build.gradle
+++ b/mediarouter/build.gradle
@@ -34,4 +34,6 @@
     mavenGroup = LibraryGroups.MEDIAROUTER
     inceptionYear = "2013"
     description = "Android MediaRouter Support Library"
+    failOnUncheckedWarnings = false
+    failOnDeprecationWarnings = false
 }
diff --git a/paging/runtime/build.gradle b/paging/runtime/build.gradle
index dd9189c..8329c05 100644
--- a/paging/runtime/build.gradle
+++ b/paging/runtime/build.gradle
@@ -48,4 +48,5 @@
     inceptionYear = "2017"
     description = "Android Paging-Runtime"
     url = SupportLibraryExtension.ARCHITECTURE_URL
+    failOnUncheckedWarnings = false
 }
diff --git a/paging/rxjava2/build.gradle b/paging/rxjava2/build.gradle
index f4c5308..2fd8caf 100644
--- a/paging/rxjava2/build.gradle
+++ b/paging/rxjava2/build.gradle
@@ -45,4 +45,5 @@
     inceptionYear = "2018"
     description = "Android Paging RXJava2"
     url = SupportLibraryExtension.ARCHITECTURE_URL
+    failOnUncheckedWarnings = false
 }
diff --git a/preference/build.gradle b/preference/build.gradle
index b7c6872..8518300 100644
--- a/preference/build.gradle
+++ b/preference/build.gradle
@@ -55,4 +55,6 @@
     mavenGroup = LibraryGroups.PREFERENCE
     inceptionYear = "2015"
     description = "Android Support Preference v7"
+    failOnUncheckedWarnings = false
+    failOnDeprecationWarnings = false
 }
diff --git a/print/build.gradle b/print/build.gradle
index 7901514..05919df 100644
--- a/print/build.gradle
+++ b/print/build.gradle
@@ -16,4 +16,5 @@
     mavenGroup = LibraryGroups.PRINT
     inceptionYear = "2018"
     description = "The Support Library is a static library that you can add to your Android application in order to use APIs that are either not available for older platform versions or utility APIs that aren't a part of the framework APIs. Compatible on devices running API 14 or later."
+    failOnDeprecationWarnings = false
 }
diff --git a/recommendation/build.gradle b/recommendation/build.gradle
index 84d0445..684726e 100644
--- a/recommendation/build.gradle
+++ b/recommendation/build.gradle
@@ -17,4 +17,5 @@
     inceptionYear = "2015"
     description = "Android Support Recommendation"
     minSdkVersion = 21
+    failOnDeprecationWarnings = false
 }
diff --git a/recyclerview-selection/build.gradle b/recyclerview-selection/build.gradle
index b467e48..dcda345 100644
--- a/recyclerview-selection/build.gradle
+++ b/recyclerview-selection/build.gradle
@@ -41,4 +41,6 @@
     mavenGroup = LibraryGroups.RECYCLERVIEW
     inceptionYear = "2017"
     description = "Library providing item selection framework for RecyclerView. Support for touch based and band selection is provided."
+    failOnUncheckedWarnings = false
+    failOnDeprecationWarnings = false
 }
diff --git a/slices/builders/build.gradle b/slices/builders/build.gradle
index 907a0b4..a9624b2 100644
--- a/slices/builders/build.gradle
+++ b/slices/builders/build.gradle
@@ -36,4 +36,6 @@
     inceptionYear = "2017"
     description = "A set of builders to create templates using SliceProvider APIs"
     minSdkVersion = 19
+    failOnUncheckedWarnings = false
+    failOnDeprecationWarnings = false
 }
diff --git a/slices/core/build.gradle b/slices/core/build.gradle
index cb17394..0530edd 100644
--- a/slices/core/build.gradle
+++ b/slices/core/build.gradle
@@ -40,4 +40,6 @@
     inceptionYear = "2017"
     description = "The slices core library provides utilities for the slices view and provider libraries"
     minSdkVersion = 19
+    failOnUncheckedWarnings = false
+    failOnDeprecationWarnings = false
 }
diff --git a/slices/view/build.gradle b/slices/view/build.gradle
index 71de3a7..5836d20 100644
--- a/slices/view/build.gradle
+++ b/slices/view/build.gradle
@@ -34,9 +34,6 @@
     androidTestImplementation(DEXMAKER_MOCKITO, libs.exclude_bytebuddy)
 }
 
-android {
-}
-
 supportLibrary {
     name = "Slice views"
     publish = true
@@ -45,4 +42,6 @@
     inceptionYear = "2017"
     description = "A library that handles rendering of slice content into supported templates"
     minSdkVersion = 19
+    failOnUncheckedWarnings = false
+    failOnDeprecationWarnings = false
 }
diff --git a/testutils/build.gradle b/testutils/build.gradle
index e0c4139..f39248e 100644
--- a/testutils/build.gradle
+++ b/testutils/build.gradle
@@ -36,3 +36,7 @@
         disable 'InvalidPackage' // Lint is unhappy about junit package
     }
 }
+
+supportLibrary {
+    failOnUncheckedWarnings = false
+}
\ No newline at end of file
diff --git a/textclassifier/build.gradle b/textclassifier/build.gradle
index fd654ee..fcaa89d 100644
--- a/textclassifier/build.gradle
+++ b/textclassifier/build.gradle
@@ -24,4 +24,5 @@
     inceptionYear = "2018"
     description = "The TextClassifier Support Library can be added to an Android application in order to use the TextClassifier API introduced in Android O on all devices with API level 14 or later."
     minSdkVersion = 14
+    failOnUncheckedWarnings = false
 }
diff --git a/transition/build.gradle b/transition/build.gradle
index 3e4e7d11..61c690f 100644
--- a/transition/build.gradle
+++ b/transition/build.gradle
@@ -36,4 +36,5 @@
     mavenGroup = LibraryGroups.TRANSITION
     inceptionYear = "2016"
     description = "Android Transition Support Library"
+    failOnDeprecationWarnings = false
 }
diff --git a/tv-provider/build.gradle b/tv-provider/build.gradle
index 9fe5f93..469f06d 100644
--- a/tv-provider/build.gradle
+++ b/tv-provider/build.gradle
@@ -23,4 +23,6 @@
     inceptionYear = "2017"
     description = "Android Support Library for TV Provider"
     minSdkVersion = 21
+    failOnUncheckedWarnings = false
+    failOnDeprecationWarnings = false
 }
\ No newline at end of file
diff --git a/v7/appcompat/build.gradle b/v7/appcompat/build.gradle
index a2ca59a..b04bee6 100644
--- a/v7/appcompat/build.gradle
+++ b/v7/appcompat/build.gradle
@@ -53,4 +53,6 @@
     mavenGroup = LibraryGroups.APPCOMPAT
     inceptionYear = "2011"
     description = "The Support Library is a static library that you can add to your Android application in order to use APIs that are either not available for older platform versions or utility APIs that aren\'t a part of the framework APIs. Compatible on devices running API 14 or later."
+    failOnUncheckedWarnings = false
+    failOnDeprecationWarnings = false
 }
diff --git a/v7/recyclerview/build.gradle b/v7/recyclerview/build.gradle
index 3e93b4e..ab5b778 100644
--- a/v7/recyclerview/build.gradle
+++ b/v7/recyclerview/build.gradle
@@ -42,4 +42,6 @@
     mavenGroup = LibraryGroups.RECYCLERVIEW
     inceptionYear = "2014"
     description = "Android Support RecyclerView v7"
+    failOnUncheckedWarnings = false
+    failOnDeprecationWarnings = false
 }
diff --git a/viewpager/build.gradle b/viewpager/build.gradle
index 02b45ba..6ba1d4d 100644
--- a/viewpager/build.gradle
+++ b/viewpager/build.gradle
@@ -24,4 +24,5 @@
     mavenGroup = LibraryGroups.VIEWPAGER
     inceptionYear = "2018"
     description = "The Support Library is a static library that you can add to your Android application in order to use APIs that are either not available for older platform versions or utility APIs that aren't a part of the framework APIs. Compatible on devices running API 14 or later."
+    failOnDeprecationWarnings = false
 }
diff --git a/wear/build.gradle b/wear/build.gradle
index c70ebef..0f606f1 100644
--- a/wear/build.gradle
+++ b/wear/build.gradle
@@ -42,4 +42,5 @@
     inceptionYear = "2016"
     description = "Android Wear Support UI"
     minSdkVersion = 23
+    failOnDeprecationWarnings = false
 }
diff --git a/webkit/build.gradle b/webkit/build.gradle
index d610dad..78a585e 100644
--- a/webkit/build.gradle
+++ b/webkit/build.gradle
@@ -51,4 +51,5 @@
     mavenGroup = LibraryGroups.WEBKIT
     inceptionYear = "2017"
     description = "The WebView Support Library is a static library you can add to your Android application in order to use android.webkit APIs that are not available for older platform versions."
+    failOnUncheckedWarnings = false
 }