Navigation Menu

Skip to content
This repository has been archived by the owner on Nov 8, 2023. It is now read-only.

Commit

Permalink
Start enforcing javac warnings.
Browse files Browse the repository at this point in the history
- 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
Merged-In: I95f73afde042a2d61984f59ee3d3350a013c0044
  • Loading branch information
liutikas committed Apr 20, 2018
1 parent 7263228 commit 3ac069f
Show file tree
Hide file tree
Showing 41 changed files with 75 additions and 3 deletions.
Expand Up @@ -65,6 +65,20 @@ class SupportAndroidLibraryPlugin : Plugin<Project> {

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"))
Expand Down
Expand Up @@ -34,6 +34,9 @@ open class SupportLibraryExtension(val project: Project) {
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
Expand Down
1 change: 1 addition & 0 deletions car/build.gradle
Expand Up @@ -54,4 +54,5 @@ supportLibrary {
description = "Android Car Support UI"
java8Library = true
minSdkVersion = 24
failOnUncheckedWarnings = false
}
1 change: 1 addition & 0 deletions cardview/build.gradle.kts
Expand Up @@ -20,4 +20,5 @@ supportLibrary {
mavenGroup = LibraryGroups.CARDVIEW
inceptionYear = "2011"
description = "Android Support CardView v7"
failOnDeprecationWarnings = false
}
2 changes: 2 additions & 0 deletions compat/build.gradle
Expand Up @@ -37,4 +37,6 @@ supportLibrary {
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
}
1 change: 1 addition & 0 deletions content/build.gradle.kts
Expand Up @@ -41,4 +41,5 @@ supportLibrary {
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
}
2 changes: 2 additions & 0 deletions coordinatorlayout/build.gradle.kts
Expand Up @@ -36,4 +36,6 @@ supportLibrary {
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
}
1 change: 1 addition & 0 deletions cursoradapter/build.gradle
Expand Up @@ -16,4 +16,5 @@ supportLibrary {
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
}
1 change: 1 addition & 0 deletions customview/build.gradle
Expand Up @@ -22,4 +22,5 @@ supportLibrary {
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
}
1 change: 1 addition & 0 deletions dynamic-animation/build.gradle
Expand Up @@ -24,4 +24,5 @@ supportLibrary {
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
}
2 changes: 2 additions & 0 deletions fragment/build.gradle
Expand Up @@ -30,4 +30,6 @@ supportLibrary {
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
}
1 change: 1 addition & 0 deletions graphics/drawable/static/build.gradle
Expand Up @@ -31,4 +31,5 @@ supportLibrary {
mavenGroup = LibraryGroups.VECTORDRAWABLE
inceptionYear = "2015"
description = "Android Support VectorDrawable"
failOnDeprecationWarnings = false
}
1 change: 1 addition & 0 deletions gridlayout/build.gradle
Expand Up @@ -21,4 +21,5 @@ supportLibrary {
mavenGroup = LibraryGroups.GRIDLAYOUT
inceptionYear = "2013"
description = "Android Support Grid Layout"
failOnDeprecationWarnings = false
}
1 change: 1 addition & 0 deletions leanback-preference/build.gradle
Expand Up @@ -30,4 +30,5 @@ supportLibrary {
inceptionYear = "2015"
description = "Android Support Leanback Preference v17"
minSdkVersion = 17
failOnDeprecationWarnings = false
}
2 changes: 2 additions & 0 deletions leanback/build.gradle
Expand Up @@ -37,4 +37,6 @@ supportLibrary {
inceptionYear = "2014"
description = "Android Support Leanback v17"
minSdkVersion = 17
failOnUncheckedWarnings = false
failOnDeprecationWarnings = false
}
1 change: 1 addition & 0 deletions legacy/v13/build.gradle
Expand Up @@ -16,4 +16,5 @@ supportLibrary {
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
}
1 change: 1 addition & 0 deletions lifecycle/extensions/build.gradle
Expand Up @@ -55,4 +55,5 @@ supportLibrary {
inceptionYear = "2017"
description = "Android Lifecycle Extensions"
url = SupportLibraryExtension.ARCHITECTURE_URL
failOnDeprecationWarnings = false
}
1 change: 1 addition & 0 deletions lifecycle/livedata-core/build.gradle
Expand Up @@ -42,4 +42,5 @@ supportLibrary {
inceptionYear = "2017"
description = "Android Lifecycle LiveData Core"
url = SupportLibraryExtension.ARCHITECTURE_URL
failOnUncheckedWarnings = false
}
1 change: 1 addition & 0 deletions lifecycle/runtime/build.gradle
Expand Up @@ -34,4 +34,5 @@ supportLibrary {
inceptionYear '2017'
description "Android Lifecycle Runtime"
url SupportLibraryExtension.ARCHITECTURE_URL
failOnDeprecationWarnings = false
}
1 change: 1 addition & 0 deletions lifecycle/viewmodel/build.gradle
Expand Up @@ -44,4 +44,5 @@ supportLibrary {
inceptionYear = "2017"
description = "Android Lifecycle ViewModel"
url = SupportLibraryExtension.ARCHITECTURE_URL
failOnUncheckedWarnings = false
}
1 change: 1 addition & 0 deletions loader/build.gradle
Expand Up @@ -25,4 +25,5 @@ supportLibrary {
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
}
2 changes: 2 additions & 0 deletions media/build.gradle
Expand Up @@ -41,4 +41,6 @@ supportLibrary {
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
}
4 changes: 4 additions & 0 deletions media/version-compat-tests/lib/build.gradle
Expand Up @@ -23,3 +23,7 @@ plugins {
dependencies {
implementation(JUNIT)
}

supportLibrary {
failOnUncheckedWarnings = false
}
2 changes: 2 additions & 0 deletions mediarouter/build.gradle
Expand Up @@ -34,4 +34,6 @@ supportLibrary {
mavenGroup = LibraryGroups.MEDIAROUTER
inceptionYear = "2013"
description = "Android MediaRouter Support Library"
failOnUncheckedWarnings = false
failOnDeprecationWarnings = false
}
1 change: 1 addition & 0 deletions paging/runtime/build.gradle
Expand Up @@ -48,4 +48,5 @@ supportLibrary {
inceptionYear = "2017"
description = "Android Paging-Runtime"
url = SupportLibraryExtension.ARCHITECTURE_URL
failOnUncheckedWarnings = false
}
1 change: 1 addition & 0 deletions paging/rxjava2/build.gradle
Expand Up @@ -45,4 +45,5 @@ supportLibrary {
inceptionYear = "2018"
description = "Android Paging RXJava2"
url = SupportLibraryExtension.ARCHITECTURE_URL
failOnUncheckedWarnings = false
}
2 changes: 2 additions & 0 deletions preference/build.gradle
Expand Up @@ -55,4 +55,6 @@ supportLibrary {
mavenGroup = LibraryGroups.PREFERENCE
inceptionYear = "2015"
description = "Android Support Preference v7"
failOnUncheckedWarnings = false
failOnDeprecationWarnings = false
}
1 change: 1 addition & 0 deletions print/build.gradle
Expand Up @@ -16,4 +16,5 @@ supportLibrary {
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
}
1 change: 1 addition & 0 deletions recommendation/build.gradle
Expand Up @@ -17,4 +17,5 @@ supportLibrary {
inceptionYear = "2015"
description = "Android Support Recommendation"
minSdkVersion = 21
failOnDeprecationWarnings = false
}
2 changes: 2 additions & 0 deletions recyclerview-selection/build.gradle
Expand Up @@ -41,4 +41,6 @@ supportLibrary {
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
}
1 change: 1 addition & 0 deletions slices/builders/build.gradle
Expand Up @@ -36,4 +36,5 @@ supportLibrary {
inceptionYear = "2017"
description = "A set of builders to create templates using SliceProvider APIs"
minSdkVersion = 19
failOnUncheckedWarnings = false
}
2 changes: 2 additions & 0 deletions slices/core/build.gradle
Expand Up @@ -40,4 +40,6 @@ supportLibrary {
inceptionYear = "2017"
description = "The slices core library provides utilities for the slices view and provider libraries"
minSdkVersion = 19
failOnUncheckedWarnings = false
failOnDeprecationWarnings = false
}
5 changes: 2 additions & 3 deletions slices/view/build.gradle
Expand Up @@ -34,9 +34,6 @@ dependencies {
androidTestImplementation(DEXMAKER_MOCKITO, libs.exclude_bytebuddy)
}

android {
}

supportLibrary {
name = "Slice views"
publish = true
Expand All @@ -45,4 +42,6 @@ supportLibrary {
inceptionYear = "2017"
description = "A library that handles rendering of slice content into supported templates"
minSdkVersion = 19
failOnUncheckedWarnings = false
failOnDeprecationWarnings = false
}
4 changes: 4 additions & 0 deletions testutils/build.gradle
Expand Up @@ -36,3 +36,7 @@ android {
disable 'InvalidPackage' // Lint is unhappy about junit package
}
}

supportLibrary {
failOnUncheckedWarnings = false
}
1 change: 1 addition & 0 deletions textclassifier/build.gradle
Expand Up @@ -24,4 +24,5 @@ supportLibrary {
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
}
1 change: 1 addition & 0 deletions transition/build.gradle
Expand Up @@ -36,4 +36,5 @@ supportLibrary {
mavenGroup = LibraryGroups.TRANSITION
inceptionYear = "2016"
description = "Android Transition Support Library"
failOnDeprecationWarnings = false
}
2 changes: 2 additions & 0 deletions tv-provider/build.gradle
Expand Up @@ -23,4 +23,6 @@ supportLibrary {
inceptionYear = "2017"
description = "Android Support Library for TV Provider"
minSdkVersion = 21
failOnUncheckedWarnings = false
failOnDeprecationWarnings = false
}
2 changes: 2 additions & 0 deletions v7/appcompat/build.gradle
Expand Up @@ -53,4 +53,6 @@ supportLibrary {
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
}
2 changes: 2 additions & 0 deletions v7/recyclerview/build.gradle
Expand Up @@ -42,4 +42,6 @@ supportLibrary {
mavenGroup = LibraryGroups.RECYCLERVIEW
inceptionYear = "2014"
description = "Android Support RecyclerView v7"
failOnUncheckedWarnings = false
failOnDeprecationWarnings = false
}
1 change: 1 addition & 0 deletions viewpager/build.gradle.kts
Expand Up @@ -24,4 +24,5 @@ supportLibrary {
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
}
1 change: 1 addition & 0 deletions wear/build.gradle
Expand Up @@ -42,4 +42,5 @@ supportLibrary {
inceptionYear = "2016"
description = "Android Wear Support UI"
minSdkVersion = 23
failOnDeprecationWarnings = false
}

0 comments on commit 3ac069f

Please sign in to comment.