Merge Flatfoot and Support library plugins

- Moves the Android Library project setup into one place
- Add an option for legacy source paths (support lib projects)
- Enables error-prone for flatfoot projects.
- Removes verbose setup of flatfoot android libraries
- Moves to referencing plugins via new plugins { id("foo") } api.

Test: ./gradlew assemble for both projects
Change-Id: I4dab611740353b0825d892169e9e7a96d900796b
diff --git a/annotations/build.gradle b/annotations/build.gradle
index dd4a5bc..2e8fbab 100644
--- a/annotations/build.gradle
+++ b/annotations/build.gradle
@@ -1,4 +1,6 @@
-apply plugin: android.support.SupportJavaLibraryPlugin
+plugins {
+    id("SupportJavaLibraryPlugin")
+}
 
 jar {
     from sourceSets.main.output
diff --git a/app-toolkit/common/build.gradle b/app-toolkit/common/build.gradle
index 4f51a49..e42dc63 100644
--- a/app-toolkit/common/build.gradle
+++ b/app-toolkit/common/build.gradle
@@ -17,7 +17,9 @@
 import android.support.LibraryVersions
 import android.support.SupportLibraryExtension;
 
-apply plugin: android.support.SupportJavaLibraryPlugin
+plugins {
+    id("SupportJavaLibraryPlugin")
+}
 
 dependencies {
     compile libs.support.annotations
diff --git a/app-toolkit/core-testing/build.gradle b/app-toolkit/core-testing/build.gradle
index 127078d..b679d98 100644
--- a/app-toolkit/core-testing/build.gradle
+++ b/app-toolkit/core-testing/build.gradle
@@ -17,22 +17,13 @@
 import android.support.LibraryVersions
 import android.support.SupportLibraryExtension
 
-apply plugin: android.support.FlatfootAndroidLibraryPlugin
+plugins {
+    id("SupportAndroidLibraryPlugin")
+}
 
 android {
-    compileSdkVersion tools.current_sdk
-    buildToolsVersion tools.build_tools_version
-
     defaultConfig {
         minSdkVersion flatfoot.min_sdk
-        targetSdkVersion tools.current_sdk
-
-        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
-    }
-
-    compileOptions {
-        sourceCompatibility JavaVersion.VERSION_1_7
-        targetCompatibility JavaVersion.VERSION_1_7
     }
 }
 
diff --git a/app-toolkit/core-testing/lint-baseline.xml b/app-toolkit/core-testing/lint-baseline.xml
new file mode 100644
index 0000000..3ce85c7
--- /dev/null
+++ b/app-toolkit/core-testing/lint-baseline.xml
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<issues format="4" by="lint 3.0.0">
+
+    <issue
+        id="InvalidPackage"
+        message="Invalid package reference in library; not included in Android: `java.lang.management`. Referenced from `org.junit.internal.runners.statements.FailOnTimeout`.">
+        <location
+            file="../../../../prebuilts/tools/common/m2/repository/junit/junit/4.12/junit-4.12.jar"/>
+    </issue>
+
+    <issue
+        id="InvalidPackage"
+        message="Invalid package reference in library; not included in Android: `java.lang.instrument`. Referenced from `org.mockito.internal.creation.bytebuddy.InlineByteBuddyMockMaker`.">
+        <location
+            file="../../../../prebuilts/tools/common/m2/repository/org/mockito/mockito-core/2.7.6/mockito-core-2.7.6.jar"/>
+    </issue>
+
+</issues>
diff --git a/app-toolkit/runtime/build.gradle b/app-toolkit/runtime/build.gradle
index 434d42b..c6badd7 100644
--- a/app-toolkit/runtime/build.gradle
+++ b/app-toolkit/runtime/build.gradle
@@ -17,26 +17,18 @@
 import android.support.SupportLibraryExtension
 import android.support.LibraryVersions
 
-apply plugin: android.support.FlatfootAndroidLibraryPlugin
+plugins {
+    id("SupportAndroidLibraryPlugin")
+}
 
 android {
-    compileSdkVersion tools.current_sdk
-    buildToolsVersion tools.build_tools_version
-
     defaultConfig {
         minSdkVersion flatfoot.min_sdk
-        targetSdkVersion tools.current_sdk
-
-        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
     }
 
     testOptions {
         unitTests.returnDefaultValues = true
     }
-    compileOptions {
-        sourceCompatibility JavaVersion.VERSION_1_7
-        targetCompatibility JavaVersion.VERSION_1_7
-    }
 }
 
 dependencies {
diff --git a/app-toolkit/runtime/lint-baseline.xml b/app-toolkit/runtime/lint-baseline.xml
new file mode 100644
index 0000000..2cadde1
--- /dev/null
+++ b/app-toolkit/runtime/lint-baseline.xml
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<issues format="4" by="lint 3.0.0">
+
+</issues>
diff --git a/buildSrc/src/main/groovy/android/support/FlatfootAndroidLibraryPlugin.groovy b/buildSrc/src/main/groovy/android/support/FlatfootAndroidLibraryPlugin.groovy
deleted file mode 100644
index 47a72d7..0000000
--- a/buildSrc/src/main/groovy/android/support/FlatfootAndroidLibraryPlugin.groovy
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package android.support
-
-import com.android.build.gradle.LibraryExtension
-import com.google.common.collect.ImmutableMap
-import org.gradle.api.Plugin
-import org.gradle.api.Project
-
-/**
- * Flatfoot Android library specific plugin that sets common configurations needed for
- * flatfoot library modules.
- */
-class FlatfootAndroidLibraryPlugin implements Plugin<Project> {
-    @Override
-    public void apply(Project project) {
-        SupportLibraryExtension supportLibraryExtension =
-                project.extensions.create("supportLibrary", SupportLibraryExtension, project);
-        SupportLibraryMavenUploader.apply(project, supportLibraryExtension);
-        VersionFileWriterTask.setUpAndroidLibrary(project);
-
-        project.apply(ImmutableMap.of("plugin", "com.android.library"));
-
-        LibraryExtension library = project.extensions.findByType(LibraryExtension.class);
-        SourceJarTaskHelper.setUpAndroidProject(project, library);
-    }
-}
\ No newline at end of file
diff --git a/buildSrc/src/main/groovy/android/support/SupportAndroidLibraryPlugin.groovy b/buildSrc/src/main/groovy/android/support/SupportAndroidLibraryPlugin.groovy
index 86469ee..c40a8be 100644
--- a/buildSrc/src/main/groovy/android/support/SupportAndroidLibraryPlugin.groovy
+++ b/buildSrc/src/main/groovy/android/support/SupportAndroidLibraryPlugin.groovy
@@ -45,6 +45,23 @@
         project.afterEvaluate {
             LibraryExtension library = project.extensions.findByType(LibraryExtension.class);
 
+            if (supportLibraryExtension.legacySourceLocation) {
+                library.sourceSets {
+                    main {
+                        // We use a non-standard manifest path.
+                        manifest.srcFile 'AndroidManifest.xml'
+                    }
+
+                    androidTest {
+                        // We use a non-standard test directory structure.
+                        root 'tests'
+                        java.srcDir 'tests/src'
+                        res.srcDir 'tests/res'
+                        manifest.srcFile 'tests/AndroidManifest.xml'
+                    }
+                }
+            }
+
             // Java 8 is only fully supported on API 24+ and not all Java 8 features are binary
             // compatible with API < 24, so use Java 7 for both source AND target.
             final JavaVersion javaVersion;
@@ -88,21 +105,6 @@
             }
         }
 
-        library.sourceSets {
-            main {
-                // We use a non-standard manifest path.
-                manifest.srcFile 'AndroidManifest.xml'
-            }
-
-            androidTest {
-                // We use a non-standard test directory structure.
-                root 'tests'
-                java.srcDir 'tests/src'
-                res.srcDir 'tests/res'
-                manifest.srcFile 'tests/AndroidManifest.xml'
-            }
-        }
-
         // Always lint check NewApi as fatal.
         library.lintOptions {
             abortOnError true
diff --git a/buildSrc/src/main/groovy/android/support/SupportLibraryExtension.groovy b/buildSrc/src/main/groovy/android/support/SupportLibraryExtension.groovy
index 93afb9a..bc26ef9 100644
--- a/buildSrc/src/main/groovy/android/support/SupportLibraryExtension.groovy
+++ b/buildSrc/src/main/groovy/android/support/SupportLibraryExtension.groovy
@@ -34,6 +34,7 @@
     String url = SUPPORT_URL;
     Collection<License> licenses = [];
     boolean java8Library = false;
+    boolean legacySourceLocation = false;
     boolean publish = false;
 
     SupportLibraryExtension(Project project) {
diff --git a/buildSrc/src/main/resources/META-INF/gradle-plugins/SupportAndroidLibraryPlugin.properties b/buildSrc/src/main/resources/META-INF/gradle-plugins/SupportAndroidLibraryPlugin.properties
new file mode 100644
index 0000000..222602b
--- /dev/null
+++ b/buildSrc/src/main/resources/META-INF/gradle-plugins/SupportAndroidLibraryPlugin.properties
@@ -0,0 +1 @@
+implementation-class=android.support.SupportAndroidLibraryPlugin
\ No newline at end of file
diff --git a/buildSrc/src/main/resources/META-INF/gradle-plugins/SupportJavaLibraryPlugin.properties b/buildSrc/src/main/resources/META-INF/gradle-plugins/SupportJavaLibraryPlugin.properties
new file mode 100644
index 0000000..89755b7
--- /dev/null
+++ b/buildSrc/src/main/resources/META-INF/gradle-plugins/SupportJavaLibraryPlugin.properties
@@ -0,0 +1 @@
+implementation-class=android.support.SupportJavaLibraryPlugin
\ No newline at end of file
diff --git a/compat/build.gradle b/compat/build.gradle
index 1e5d847..e81bf25 100644
--- a/compat/build.gradle
+++ b/compat/build.gradle
@@ -1,4 +1,6 @@
-apply plugin: android.support.SupportAndroidLibraryPlugin
+plugins {
+    id("SupportAndroidLibraryPlugin")
+}
 
 dependencies {
     api project(':support-annotations')
@@ -34,4 +36,5 @@
     publish true
     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."
+    legacySourceLocation true
 }
diff --git a/content/build.gradle b/content/build.gradle
index af33423..9d4842b 100644
--- a/content/build.gradle
+++ b/content/build.gradle
@@ -14,7 +14,9 @@
  * limitations under the License.
  */
 
-apply plugin: android.support.SupportAndroidLibraryPlugin
+plugins {
+    id("SupportAndroidLibraryPlugin")
+}
 
 dependencies {
     api project(':support-annotations')
@@ -36,4 +38,5 @@
     publish true
     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.'
+    legacySourceLocation true
 }
diff --git a/core-ui/build.gradle b/core-ui/build.gradle
index 38a4fe2..19ed3da 100644
--- a/core-ui/build.gradle
+++ b/core-ui/build.gradle
@@ -1,4 +1,6 @@
-apply plugin: android.support.SupportAndroidLibraryPlugin
+plugins {
+    id("SupportAndroidLibraryPlugin")
+}
 
 dependencies {
     api project(':support-annotations')
@@ -26,4 +28,5 @@
     publish true
     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."
+    legacySourceLocation true
 }
diff --git a/core-utils/build.gradle b/core-utils/build.gradle
index 55fe2bb..35923bd 100644
--- a/core-utils/build.gradle
+++ b/core-utils/build.gradle
@@ -1,4 +1,6 @@
-apply plugin: android.support.SupportAndroidLibraryPlugin
+plugins {
+    id("SupportAndroidLibraryPlugin")
+}
 
 dependencies {
     api project(':support-annotations')
@@ -21,4 +23,5 @@
     publish true
     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."
+    legacySourceLocation true
 }
diff --git a/customtabs/build.gradle b/customtabs/build.gradle
index fc90301..c928235 100644
--- a/customtabs/build.gradle
+++ b/customtabs/build.gradle
@@ -1,4 +1,6 @@
-apply plugin: android.support.SupportAndroidLibraryPlugin
+plugins {
+    id("SupportAndroidLibraryPlugin")
+}
 
 dependencies {
     api project(':support-compat')
@@ -24,4 +26,5 @@
     publish true
     inceptionYear '2015'
     description 'Android Support Custom Tabs'
+    legacySourceLocation true
 }
diff --git a/design/build.gradle b/design/build.gradle
index 4a82051..e024638 100644
--- a/design/build.gradle
+++ b/design/build.gradle
@@ -1,4 +1,6 @@
-apply plugin: android.support.SupportAndroidLibraryPlugin
+plugins {
+    id("SupportAndroidLibraryPlugin")
+}
 
 dependencies {
     api project(':support-v4')
@@ -63,4 +65,5 @@
     publish true
     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."
+    legacySourceLocation true
 }
diff --git a/dynamic-animation/build.gradle b/dynamic-animation/build.gradle
index 220758d..45af6f7 100644
--- a/dynamic-animation/build.gradle
+++ b/dynamic-animation/build.gradle
@@ -1,4 +1,6 @@
-apply plugin: android.support.SupportAndroidLibraryPlugin
+plugins {
+    id("SupportAndroidLibraryPlugin")
+}
 
 dependencies {
     api project(':support-core-utils')
@@ -20,4 +22,5 @@
     publish true
     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."
+    legacySourceLocation true
 }
\ No newline at end of file
diff --git a/emoji/appcompat/build.gradle b/emoji/appcompat/build.gradle
index e22000c..f856149 100644
--- a/emoji/appcompat/build.gradle
+++ b/emoji/appcompat/build.gradle
@@ -14,7 +14,9 @@
  * limitations under the License.
  */
 
-apply plugin: android.support.SupportAndroidLibraryPlugin
+plugins {
+    id("SupportAndroidLibraryPlugin")
+}
 
 dependencies {
     api fileTree(include: ['*.jar'], dir: 'libs')
@@ -33,4 +35,5 @@
     publish true
     inceptionYear '2017'
     description 'EmojiCompat Widgets for AppCompat integration'
+    legacySourceLocation true
 }
\ No newline at end of file
diff --git a/emoji/bundled/build.gradle b/emoji/bundled/build.gradle
index 766d165..7e22307 100644
--- a/emoji/bundled/build.gradle
+++ b/emoji/bundled/build.gradle
@@ -1,4 +1,6 @@
-apply plugin: android.support.SupportAndroidLibraryPlugin
+plugins {
+    id("SupportAndroidLibraryPlugin")
+}
 
 ext {
     fontDir = project(':noto-emoji-compat').projectDir
@@ -33,4 +35,5 @@
         name 'Unicode, Inc. License'
         url 'http://www.unicode.org/copyright.html#License'
     }
+    legacySourceLocation true
 }
\ No newline at end of file
diff --git a/emoji/core/build.gradle b/emoji/core/build.gradle
index b4cd3fc..3ebd2dc 100644
--- a/emoji/core/build.gradle
+++ b/emoji/core/build.gradle
@@ -1,4 +1,6 @@
-apply plugin: android.support.SupportAndroidLibraryPlugin
+plugins {
+    id("SupportAndroidLibraryPlugin")
+}
 
 ext {
     fontDir = project(':noto-emoji-compat').projectDir
@@ -29,13 +31,22 @@
     }
 
     sourceSets {
-        main.res.srcDirs += 'src/main/res-public'
-        main.resources {
-            srcDirs = [fontDir.getAbsolutePath()]
-            includes = ["LICENSE_UNICODE", "LICENSE_OFL"]
+        main {
+            // We use a non-standard manifest path.
+            manifest.srcFile 'AndroidManifest.xml'
+            res.srcDirs += 'src/main/res-public'
+            resources {
+                srcDirs = [fontDir.getAbsolutePath()]
+                includes = ["LICENSE_UNICODE", "LICENSE_OFL"]
+            }
         }
 
         androidTest {
+            // We use a non-standard test directory structure.
+            root 'tests'
+            java.srcDir 'tests/src'
+            res.srcDir 'tests/res'
+            manifest.srcFile 'tests/AndroidManifest.xml'
             assets {
                 srcDirs = [new File(fontDir, "font").getAbsolutePath(),
                            new File(fontDir, "supported-emojis").getAbsolutePath()]
diff --git a/exifinterface/build.gradle b/exifinterface/build.gradle
index 3e034b1..14c5192 100644
--- a/exifinterface/build.gradle
+++ b/exifinterface/build.gradle
@@ -1,4 +1,6 @@
-apply plugin: android.support.SupportAndroidLibraryPlugin
+plugins {
+    id("SupportAndroidLibraryPlugin")
+}
 
 dependencies {
     api project(':support-annotations')
@@ -17,4 +19,5 @@
     publish true
     inceptionYear '2016'
     description 'Android Support ExifInterface'
+    legacySourceLocation true
 }
diff --git a/fragment/build.gradle b/fragment/build.gradle
index 3a86f38..0bfe003 100644
--- a/fragment/build.gradle
+++ b/fragment/build.gradle
@@ -1,4 +1,6 @@
-apply plugin: android.support.SupportAndroidLibraryPlugin
+plugins {
+    id("SupportAndroidLibraryPlugin")
+}
 
 dependencies {
     api project(':support-compat')
@@ -23,5 +25,6 @@
     publish true
     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."
+    legacySourceLocation true
 }
 
diff --git a/graphics/drawable/animated/build.gradle b/graphics/drawable/animated/build.gradle
index 6036284..7695460 100644
--- a/graphics/drawable/animated/build.gradle
+++ b/graphics/drawable/animated/build.gradle
@@ -1,4 +1,6 @@
-apply plugin: android.support.SupportAndroidLibraryPlugin
+plugins {
+    id("SupportAndroidLibraryPlugin")
+}
 
 dependencies {
     api project(':support-vector-drawable')
@@ -29,4 +31,5 @@
     publish true
     inceptionYear '2015'
     description 'Android Support AnimatedVectorDrawable'
+    legacySourceLocation true
 }
\ No newline at end of file
diff --git a/graphics/drawable/static/build.gradle b/graphics/drawable/static/build.gradle
index 949ba89..cb24111 100644
--- a/graphics/drawable/static/build.gradle
+++ b/graphics/drawable/static/build.gradle
@@ -1,4 +1,6 @@
-apply plugin: android.support.SupportAndroidLibraryPlugin
+plugins {
+    id("SupportAndroidLibraryPlugin")
+}
 
 dependencies {
     api project(':support-annotations')
@@ -24,4 +26,5 @@
     publish true
     inceptionYear '2015'
     description 'Android Support VectorDrawable'
-}
+    legacySourceLocation true
+}
\ No newline at end of file
diff --git a/lifecycle/common-java8/build.gradle b/lifecycle/common-java8/build.gradle
index fccc813..d5cf463 100644
--- a/lifecycle/common-java8/build.gradle
+++ b/lifecycle/common-java8/build.gradle
@@ -17,7 +17,9 @@
 import android.support.LibraryVersions;
 import android.support.SupportLibraryExtension;
 
-apply plugin: android.support.SupportJavaLibraryPlugin
+plugins {
+    id("SupportJavaLibraryPlugin")
+}
 
 dependencies {
     testCompile libs.junit
diff --git a/lifecycle/common/build.gradle b/lifecycle/common/build.gradle
index 57cfd00..82f55ba 100644
--- a/lifecycle/common/build.gradle
+++ b/lifecycle/common/build.gradle
@@ -17,7 +17,9 @@
 import android.support.LibraryVersions;
 import android.support.SupportLibraryExtension;
 
-apply plugin: android.support.SupportJavaLibraryPlugin
+plugins {
+    id("SupportJavaLibraryPlugin")
+}
 
 dependencies {
     testCompile libs.junit
diff --git a/lifecycle/extensions/build.gradle b/lifecycle/extensions/build.gradle
index 79be36c..27ca284 100644
--- a/lifecycle/extensions/build.gradle
+++ b/lifecycle/extensions/build.gradle
@@ -17,17 +17,11 @@
 import android.support.LibraryVersions
 import android.support.SupportLibraryExtension
 
-apply plugin: android.support.FlatfootAndroidLibraryPlugin
+apply plugin: android.support.SupportAndroidLibraryPlugin
 
 android {
-    compileSdkVersion tools.current_sdk
-    buildToolsVersion tools.build_tools_version
-
     defaultConfig {
         minSdkVersion flatfoot.min_sdk
-        targetSdkVersion tools.current_sdk
-
-        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
     }
 
     buildTypes.all {
diff --git a/lifecycle/extensions/lint-baseline.xml b/lifecycle/extensions/lint-baseline.xml
new file mode 100644
index 0000000..2cadde1
--- /dev/null
+++ b/lifecycle/extensions/lint-baseline.xml
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<issues format="4" by="lint 3.0.0">
+
+</issues>
diff --git a/lifecycle/extensions/src/main/java/android/arch/lifecycle/AndroidViewModel.java b/lifecycle/extensions/src/main/java/android/arch/lifecycle/AndroidViewModel.java
index 106b2ef..e8895bd 100644
--- a/lifecycle/extensions/src/main/java/android/arch/lifecycle/AndroidViewModel.java
+++ b/lifecycle/extensions/src/main/java/android/arch/lifecycle/AndroidViewModel.java
@@ -37,6 +37,7 @@
     /**
      * Return the application.
      */
+    @SuppressWarnings("TypeParameterUnusedInFormals")
     @NonNull
     public <T extends Application> T getApplication() {
         //noinspection unchecked
diff --git a/lifecycle/extensions/src/main/java/android/arch/lifecycle/ViewModelProvider.java b/lifecycle/extensions/src/main/java/android/arch/lifecycle/ViewModelProvider.java
index 29cbab8..a7b3aeb 100644
--- a/lifecycle/extensions/src/main/java/android/arch/lifecycle/ViewModelProvider.java
+++ b/lifecycle/extensions/src/main/java/android/arch/lifecycle/ViewModelProvider.java
@@ -138,6 +138,7 @@
      */
     public static class NewInstanceFactory implements Factory {
 
+        @SuppressWarnings("ClassNewInstance")
         @NonNull
         @Override
         public <T extends ViewModel> T create(@NonNull Class<T> modelClass) {
diff --git a/lifecycle/reactivestreams/build.gradle b/lifecycle/reactivestreams/build.gradle
index bd64a32..eb8d63c 100644
--- a/lifecycle/reactivestreams/build.gradle
+++ b/lifecycle/reactivestreams/build.gradle
@@ -17,17 +17,13 @@
 import android.support.LibraryVersions
 import android.support.SupportLibraryExtension
 
-apply plugin: android.support.FlatfootAndroidLibraryPlugin
+plugins {
+    id("SupportAndroidLibraryPlugin")
+}
 
 android {
-    compileSdkVersion tools.current_sdk
-    buildToolsVersion tools.build_tools_version
-
     defaultConfig {
         minSdkVersion flatfoot.min_sdk
-        targetSdkVersion tools.current_sdk
-
-        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
     }
 
     testOptions {
diff --git a/lifecycle/reactivestreams/lint-baseline.xml b/lifecycle/reactivestreams/lint-baseline.xml
new file mode 100644
index 0000000..2cadde1
--- /dev/null
+++ b/lifecycle/reactivestreams/lint-baseline.xml
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<issues format="4" by="lint 3.0.0">
+
+</issues>
diff --git a/lifecycle/runtime/build.gradle b/lifecycle/runtime/build.gradle
index 111429c..0acf62e 100644
--- a/lifecycle/runtime/build.gradle
+++ b/lifecycle/runtime/build.gradle
@@ -1,18 +1,13 @@
 import android.support.LibraryVersions
-
 import android.support.SupportLibraryExtension
 
-apply plugin: android.support.FlatfootAndroidLibraryPlugin
+plugins {
+    id("SupportAndroidLibraryPlugin")
+}
 
 android {
-    compileSdkVersion tools.current_sdk
-    buildToolsVersion tools.build_tools_version
-
     defaultConfig {
         minSdkVersion flatfoot.min_sdk
-        targetSdkVersion tools.current_sdk
-
-        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
     }
 
     buildTypes.all {
diff --git a/lifecycle/runtime/lint-baseline.xml b/lifecycle/runtime/lint-baseline.xml
new file mode 100644
index 0000000..2cadde1
--- /dev/null
+++ b/lifecycle/runtime/lint-baseline.xml
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<issues format="4" by="lint 3.0.0">
+
+</issues>
diff --git a/media-compat-test-client/build.gradle b/media-compat-test-client/build.gradle
index e4cec1d..76fc2be 100644
--- a/media-compat-test-client/build.gradle
+++ b/media-compat-test-client/build.gradle
@@ -13,7 +13,10 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-apply plugin: android.support.SupportAndroidLibraryPlugin
+
+plugins {
+    id("SupportAndroidLibraryPlugin")
+}
 
 dependencies {
     androidTestImplementation project(':support-annotations')
@@ -30,4 +33,8 @@
     defaultConfig {
         minSdkVersion 14
     }
+}
+
+supportLibrary {
+    legacySourceLocation true
 }
\ No newline at end of file
diff --git a/media-compat-test-service/build.gradle b/media-compat-test-service/build.gradle
index 1912719..87c8bd1 100644
--- a/media-compat-test-service/build.gradle
+++ b/media-compat-test-service/build.gradle
@@ -13,7 +13,10 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-apply plugin: android.support.SupportAndroidLibraryPlugin
+
+plugins {
+    id("SupportAndroidLibraryPlugin")
+}
 
 dependencies {
     androidTestImplementation project(':support-annotations')
@@ -30,3 +33,7 @@
         minSdkVersion 14
     }
 }
+
+supportLibrary {
+    legacySourceLocation true
+}
diff --git a/media-compat/build.gradle b/media-compat/build.gradle
index c504996..eeeb3db 100644
--- a/media-compat/build.gradle
+++ b/media-compat/build.gradle
@@ -1,4 +1,6 @@
-apply plugin: android.support.SupportAndroidLibraryPlugin
+plugins {
+    id("SupportAndroidLibraryPlugin")
+}
 
 dependencies {
     api project(':support-annotations')
@@ -39,4 +41,5 @@
     publish true
     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."
+    legacySourceLocation true
 }
diff --git a/paging/common/build.gradle b/paging/common/build.gradle
index bb9ad6b..93d4437 100644
--- a/paging/common/build.gradle
+++ b/paging/common/build.gradle
@@ -17,8 +17,10 @@
 import android.support.LibraryVersions
 import android.support.SupportLibraryExtension;
 
-apply plugin: android.support.SupportJavaLibraryPlugin
-apply plugin: 'kotlin'
+plugins {
+    id("SupportJavaLibraryPlugin")
+    id("kotlin")
+}
 
 dependencies {
     compile libs.support.annotations
diff --git a/paging/runtime/build.gradle b/paging/runtime/build.gradle
index c318c65..936e482 100644
--- a/paging/runtime/build.gradle
+++ b/paging/runtime/build.gradle
@@ -17,23 +17,14 @@
 import android.support.LibraryVersions
 import android.support.SupportLibraryExtension
 
-apply plugin: android.support.FlatfootAndroidLibraryPlugin
-apply plugin: 'kotlin-android'
+plugins {
+    id("SupportAndroidLibraryPlugin")
+    id("kotlin-android")
+}
 
 android {
-    compileSdkVersion tools.current_sdk
-    buildToolsVersion tools.build_tools_version
-
     defaultConfig {
         minSdkVersion flatfoot.min_sdk
-        targetSdkVersion tools.current_sdk
-
-        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
-    }
-
-    compileOptions {
-        sourceCompatibility JavaVersion.VERSION_1_7
-        targetCompatibility JavaVersion.VERSION_1_7
     }
 }
 
diff --git a/paging/runtime/lint-baseline.xml b/paging/runtime/lint-baseline.xml
new file mode 100644
index 0000000..2cadde1
--- /dev/null
+++ b/paging/runtime/lint-baseline.xml
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<issues format="4" by="lint 3.0.0">
+
+</issues>
diff --git a/percent/build.gradle b/percent/build.gradle
index aecaa28..fdf94ca 100644
--- a/percent/build.gradle
+++ b/percent/build.gradle
@@ -1,4 +1,6 @@
-apply plugin: android.support.SupportAndroidLibraryPlugin
+plugins {
+    id("SupportAndroidLibraryPlugin")
+}
 
 dependencies {
     api project(':support-compat')
@@ -22,4 +24,5 @@
     publish true
     inceptionYear '2015'
     description 'Android Percent Support Library'
+    legacySourceLocation true
 }
diff --git a/persistence/db-framework/build.gradle b/persistence/db-framework/build.gradle
index 0961ba5..cc652c2 100644
--- a/persistence/db-framework/build.gradle
+++ b/persistence/db-framework/build.gradle
@@ -17,27 +17,18 @@
 import android.support.LibraryVersions
 import android.support.SupportLibraryExtension
 
-apply plugin: android.support.FlatfootAndroidLibraryPlugin
+plugins {
+    id("SupportAndroidLibraryPlugin")
+}
 
 android {
-    compileSdkVersion tools.current_sdk
-    buildToolsVersion tools.build_tools_version
-
     defaultConfig {
         minSdkVersion flatfoot.min_sdk
-        targetSdkVersion tools.current_sdk
-
-        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
-
     }
 
     testOptions {
         unitTests.returnDefaultValues = true
     }
-    compileOptions {
-        sourceCompatibility JavaVersion.VERSION_1_7
-        targetCompatibility JavaVersion.VERSION_1_7
-    }
 }
 
 dependencies {
diff --git a/persistence/db-framework/lint-baseline.xml b/persistence/db-framework/lint-baseline.xml
new file mode 100644
index 0000000..2cadde1
--- /dev/null
+++ b/persistence/db-framework/lint-baseline.xml
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<issues format="4" by="lint 3.0.0">
+
+</issues>
diff --git a/persistence/db/build.gradle b/persistence/db/build.gradle
index 4757a79..9cb663f 100644
--- a/persistence/db/build.gradle
+++ b/persistence/db/build.gradle
@@ -17,27 +17,18 @@
 import android.support.LibraryVersions
 import android.support.SupportLibraryExtension
 
-apply plugin: android.support.FlatfootAndroidLibraryPlugin
+plugins {
+    id("SupportAndroidLibraryPlugin")
+}
 
 android {
-    compileSdkVersion tools.current_sdk
-    buildToolsVersion tools.build_tools_version
-
     defaultConfig {
         minSdkVersion flatfoot.min_sdk
-        targetSdkVersion tools.current_sdk
-
-        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
-
     }
 
     testOptions {
         unitTests.returnDefaultValues = true
     }
-    compileOptions {
-        sourceCompatibility JavaVersion.VERSION_1_7
-        targetCompatibility JavaVersion.VERSION_1_7
-    }
 }
 
 dependencies {
diff --git a/persistence/db/lint-baseline.xml b/persistence/db/lint-baseline.xml
new file mode 100644
index 0000000..2cadde1
--- /dev/null
+++ b/persistence/db/lint-baseline.xml
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<issues format="4" by="lint 3.0.0">
+
+</issues>
diff --git a/recommendation/build.gradle b/recommendation/build.gradle
index 0c38487..7b65525 100644
--- a/recommendation/build.gradle
+++ b/recommendation/build.gradle
@@ -1,4 +1,6 @@
-apply plugin: android.support.SupportAndroidLibraryPlugin
+plugins {
+    id("SupportAndroidLibraryPlugin")
+}
 
 dependencies {
     api project(':support-annotations')
@@ -15,4 +17,5 @@
     publish true
     inceptionYear '2015'
     description 'Android Support Recommendation'
+    legacySourceLocation true
 }
diff --git a/room/common/build.gradle b/room/common/build.gradle
index 4336583..dbc84f5 100644
--- a/room/common/build.gradle
+++ b/room/common/build.gradle
@@ -17,7 +17,9 @@
 import android.support.LibraryVersions
 import android.support.SupportLibraryExtension;
 
-apply plugin: android.support.SupportJavaLibraryPlugin
+plugins {
+    id("SupportJavaLibraryPlugin")
+}
 
 dependencies {
     compile libs.support.annotations
diff --git a/room/migration/build.gradle b/room/migration/build.gradle
index 3f5bdd6..d6550ac 100644
--- a/room/migration/build.gradle
+++ b/room/migration/build.gradle
@@ -17,7 +17,9 @@
 import android.support.LibraryVersions
 import android.support.SupportLibraryExtension;
 
-apply plugin: android.support.SupportJavaLibraryPlugin
+plugins {
+    id("SupportJavaLibraryPlugin")
+}
 
 sourceSets {
     test.java.srcDirs += 'src/tests/kotlin'
diff --git a/room/runtime/build.gradle b/room/runtime/build.gradle
index a170c8e..d79dfb6 100644
--- a/room/runtime/build.gradle
+++ b/room/runtime/build.gradle
@@ -17,18 +17,13 @@
 import android.support.LibraryVersions
 import android.support.SupportLibraryExtension
 
-apply plugin: android.support.FlatfootAndroidLibraryPlugin
+plugins {
+    id("SupportAndroidLibraryPlugin")
+}
 
 android {
-    compileSdkVersion tools.current_sdk
-    buildToolsVersion tools.build_tools_version
-
     defaultConfig {
         minSdkVersion flatfoot.min_sdk
-        targetSdkVersion tools.current_sdk
-
-        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
-
     }
 
     buildTypes.all {
@@ -38,10 +33,6 @@
     testOptions {
         unitTests.returnDefaultValues = true
     }
-    compileOptions {
-        sourceCompatibility JavaVersion.VERSION_1_7
-        targetCompatibility JavaVersion.VERSION_1_7
-    }
 }
 
 dependencies {
diff --git a/room/runtime/lint-baseline.xml b/room/runtime/lint-baseline.xml
new file mode 100644
index 0000000..2cadde1
--- /dev/null
+++ b/room/runtime/lint-baseline.xml
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<issues format="4" by="lint 3.0.0">
+
+</issues>
diff --git a/room/runtime/src/main/java/android/arch/persistence/room/EntityDeletionOrUpdateAdapter.java b/room/runtime/src/main/java/android/arch/persistence/room/EntityDeletionOrUpdateAdapter.java
index 6f4aa68..373b122 100644
--- a/room/runtime/src/main/java/android/arch/persistence/room/EntityDeletionOrUpdateAdapter.java
+++ b/room/runtime/src/main/java/android/arch/persistence/room/EntityDeletionOrUpdateAdapter.java
@@ -45,6 +45,7 @@
      *
      * @return An SQL query that can delete or update instances of T.
      */
+    @Override
     protected abstract String createQuery();
 
     /**
diff --git a/room/runtime/src/main/java/android/arch/persistence/room/Room.java b/room/runtime/src/main/java/android/arch/persistence/room/Room.java
index 2850b55..9b168fc 100644
--- a/room/runtime/src/main/java/android/arch/persistence/room/Room.java
+++ b/room/runtime/src/main/java/android/arch/persistence/room/Room.java
@@ -72,6 +72,7 @@
         return new RoomDatabase.Builder<>(context, klass, null);
     }
 
+    @SuppressWarnings({"TypeParameterUnusedInFormals", "ClassNewInstance"})
     @NonNull
     static <T, C> T getGeneratedImplementation(Class<C> klass, String suffix) {
         final String fullPackage = klass.getPackage().getName();
diff --git a/room/rxjava2/build.gradle b/room/rxjava2/build.gradle
index 7f86842..c75f29c 100644
--- a/room/rxjava2/build.gradle
+++ b/room/rxjava2/build.gradle
@@ -17,33 +17,18 @@
 import android.support.LibraryVersions
 import android.support.SupportLibraryExtension
 
-apply plugin: android.support.FlatfootAndroidLibraryPlugin
+plugins {
+    id("SupportAndroidLibraryPlugin")
+}
 
 android {
-    compileSdkVersion tools.current_sdk
-    buildToolsVersion tools.build_tools_version
-
     defaultConfig {
         minSdkVersion flatfoot.min_sdk
-        targetSdkVersion tools.current_sdk
-
-        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
-
-    }
-    buildTypes {
-        release {
-            minifyEnabled false
-            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
-        }
     }
 
     testOptions {
         unitTests.returnDefaultValues = true
     }
-    compileOptions {
-        sourceCompatibility JavaVersion.VERSION_1_7
-        targetCompatibility JavaVersion.VERSION_1_7
-    }
 }
 
 dependencies {
diff --git a/room/rxjava2/lint-baseline.xml b/room/rxjava2/lint-baseline.xml
new file mode 100644
index 0000000..2cadde1
--- /dev/null
+++ b/room/rxjava2/lint-baseline.xml
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<issues format="4" by="lint 3.0.0">
+
+</issues>
diff --git a/room/testing/build.gradle b/room/testing/build.gradle
index 078de88..4af1f3c 100644
--- a/room/testing/build.gradle
+++ b/room/testing/build.gradle
@@ -17,26 +17,18 @@
 import android.support.LibraryVersions
 import android.support.SupportLibraryExtension
 
-apply plugin: android.support.FlatfootAndroidLibraryPlugin
+plugins {
+    id("SupportAndroidLibraryPlugin")
+}
 
 android {
-    compileSdkVersion tools.current_sdk
-    buildToolsVersion tools.build_tools_version
-
     defaultConfig {
         minSdkVersion flatfoot.min_sdk
-        targetSdkVersion tools.current_sdk
-
-        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
     }
 
     testOptions {
         unitTests.returnDefaultValues = true
     }
-    compileOptions {
-        sourceCompatibility JavaVersion.VERSION_1_7
-        targetCompatibility JavaVersion.VERSION_1_7
-    }
 }
 
 dependencies {
diff --git a/room/testing/lint-baseline.xml b/room/testing/lint-baseline.xml
new file mode 100644
index 0000000..dee4355
--- /dev/null
+++ b/room/testing/lint-baseline.xml
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<issues format="4" by="lint 3.0.0">
+
+    <issue
+        id="InvalidPackage"
+        message="Invalid package reference in library; not included in Android: `java.lang.management`. Referenced from `org.junit.internal.runners.statements.FailOnTimeout`.">
+        <location
+            file="../../../../prebuilts/tools/common/m2/repository/junit/junit/4.12/junit-4.12.jar"/>
+    </issue>
+
+</issues>
diff --git a/room/testing/src/main/java/android/arch/persistence/room/testing/MigrationTestHelper.java b/room/testing/src/main/java/android/arch/persistence/room/testing/MigrationTestHelper.java
index 18e0a14..2e93bbe 100644
--- a/room/testing/src/main/java/android/arch/persistence/room/testing/MigrationTestHelper.java
+++ b/room/testing/src/main/java/android/arch/persistence/room/testing/MigrationTestHelper.java
@@ -341,7 +341,7 @@
         return 0;
     }
 
-    class MigratingDelegate extends RoomOpenHelperDelegate {
+    static class MigratingDelegate extends RoomOpenHelperDelegate {
         private final boolean mVerifyDroppedTables;
 
         MigratingDelegate(DatabaseBundle databaseBundle, boolean verifyDroppedTables) {
diff --git a/testutils/build.gradle b/testutils/build.gradle
index f1be70d..918db1a 100644
--- a/testutils/build.gradle
+++ b/testutils/build.gradle
@@ -14,7 +14,9 @@
  * limitations under the License.
  */
 
-apply plugin: android.support.SupportAndroidLibraryPlugin
+plugins {
+    id("SupportAndroidLibraryPlugin")
+}
 
 dependencies {
     compile libs.junit
@@ -27,4 +29,8 @@
     lintOptions {
         disable 'InvalidPackage' // Lint is unhappy about junit package
     }
+}
+
+supportLibrary {
+    legacySourceLocation true
 }
\ No newline at end of file
diff --git a/transition/build.gradle b/transition/build.gradle
index be366d6..d101b64 100644
--- a/transition/build.gradle
+++ b/transition/build.gradle
@@ -1,4 +1,6 @@
-apply plugin: android.support.SupportAndroidLibraryPlugin
+plugins {
+    id("SupportAndroidLibraryPlugin")
+}
 
 dependencies {
     api project(':support-annotations')
@@ -48,4 +50,5 @@
     publish true
     inceptionYear '2016'
     description 'Android Transition Support Library'
+    legacySourceLocation true
 }
diff --git a/tv-provider/build.gradle b/tv-provider/build.gradle
index 0545458..c44cfbb 100644
--- a/tv-provider/build.gradle
+++ b/tv-provider/build.gradle
@@ -1,4 +1,6 @@
-apply plugin: android.support.SupportAndroidLibraryPlugin
+plugins {
+    id("SupportAndroidLibraryPlugin")
+}
 
 dependencies {
     api project(':support-annotations')
@@ -18,4 +20,5 @@
     publish true
     inceptionYear '2017'
     description 'Android Support Library for TV Provider'
+    legacySourceLocation true
 }
\ No newline at end of file
diff --git a/v13/build.gradle b/v13/build.gradle
index 06774fd..cf2b100 100644
--- a/v13/build.gradle
+++ b/v13/build.gradle
@@ -1,4 +1,6 @@
-apply plugin: android.support.SupportAndroidLibraryPlugin
+plugins {
+    id("SupportAndroidLibraryPlugin")
+}
 
 dependencies {
     api project(':support-annotations')
@@ -27,4 +29,5 @@
     publish true
     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."
+    legacySourceLocation true
 }
diff --git a/v14/preference/build.gradle b/v14/preference/build.gradle
index 8c66d6a..2adeda7 100644
--- a/v14/preference/build.gradle
+++ b/v14/preference/build.gradle
@@ -14,7 +14,9 @@
  * limitations under the License
  */
 
-apply plugin: android.support.SupportAndroidLibraryPlugin
+plugins {
+    id("SupportAndroidLibraryPlugin")
+}
 
 dependencies {
     api project(':support-v4')
@@ -38,4 +40,5 @@
     publish true
     inceptionYear '2015'
     description 'Android Support Preference v14'
+    legacySourceLocation true
 }
diff --git a/v17/leanback/build.gradle b/v17/leanback/build.gradle
index baefe46..b0f5abf 100644
--- a/v17/leanback/build.gradle
+++ b/v17/leanback/build.gradle
@@ -1,4 +1,6 @@
-apply plugin: android.support.SupportAndroidLibraryPlugin
+plugins {
+    id("SupportAndroidLibraryPlugin")
+}
 
 dependencies {
     api project(':support-compat')
@@ -35,4 +37,5 @@
     publish true
     inceptionYear '2014'
     description 'Android Support Leanback v17'
+    legacySourceLocation true
 }
diff --git a/v17/preference-leanback/build.gradle b/v17/preference-leanback/build.gradle
index f573908..bf6d0e7 100644
--- a/v17/preference-leanback/build.gradle
+++ b/v17/preference-leanback/build.gradle
@@ -1,4 +1,6 @@
-apply plugin: android.support.SupportAndroidLibraryPlugin
+plugins {
+    id("SupportAndroidLibraryPlugin")
+}
 
 dependencies {
     api project(':support-v4')
@@ -28,4 +30,5 @@
     publish true
     inceptionYear '2015'
     description 'Android Support Leanback Preference v17'
+    legacySourceLocation true
 }
\ No newline at end of file
diff --git a/v4/build.gradle b/v4/build.gradle
index 737db27..aa739b3 100644
--- a/v4/build.gradle
+++ b/v4/build.gradle
@@ -1,4 +1,6 @@
-apply plugin: android.support.SupportAndroidLibraryPlugin
+plugins {
+    id("SupportAndroidLibraryPlugin")
+}
 
 dependencies {
     api project(':support-compat')
@@ -21,4 +23,5 @@
     publish true
     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."
+    legacySourceLocation true
 }
diff --git a/v7/appcompat/build.gradle b/v7/appcompat/build.gradle
index 2d57ac4..88c1980 100644
--- a/v7/appcompat/build.gradle
+++ b/v7/appcompat/build.gradle
@@ -1,4 +1,6 @@
-apply plugin: android.support.SupportAndroidLibraryPlugin
+plugins {
+    id("SupportAndroidLibraryPlugin")
+}
 
 dependencies {
     api project(':support-annotations')
@@ -36,4 +38,5 @@
     publish true
     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."
+    legacySourceLocation true
 }
diff --git a/v7/cardview/build.gradle b/v7/cardview/build.gradle
index 76c3bf3..8ed0e93 100644
--- a/v7/cardview/build.gradle
+++ b/v7/cardview/build.gradle
@@ -1,4 +1,6 @@
-apply plugin: android.support.SupportAndroidLibraryPlugin
+plugins {
+    id("SupportAndroidLibraryPlugin")
+}
 
 dependencies {
     api project(':support-annotations')
@@ -19,4 +21,5 @@
     publish true
     inceptionYear '2011'
     description 'Android Support CardView v7'
+    legacySourceLocation true
 }
diff --git a/v7/gridlayout/build.gradle b/v7/gridlayout/build.gradle
index d4d467d..aaceec0 100644
--- a/v7/gridlayout/build.gradle
+++ b/v7/gridlayout/build.gradle
@@ -1,4 +1,6 @@
-apply plugin: android.support.SupportAndroidLibraryPlugin
+plugins {
+    id("SupportAndroidLibraryPlugin")
+}
 
 dependencies {
     api project(':support-compat')
@@ -23,4 +25,5 @@
     publish true
     inceptionYear '2013'
     description 'Android Support Grid Layout'
+    legacySourceLocation true
 }
diff --git a/v7/mediarouter/build.gradle b/v7/mediarouter/build.gradle
index f301324..42d9036 100644
--- a/v7/mediarouter/build.gradle
+++ b/v7/mediarouter/build.gradle
@@ -1,4 +1,6 @@
-apply plugin: android.support.SupportAndroidLibraryPlugin
+plugins {
+    id("SupportAndroidLibraryPlugin")
+}
 
 dependencies {
     api project(":support-media-compat")
@@ -32,4 +34,5 @@
     publish true
     inceptionYear '2013'
     description 'Android MediaRouter Support Library'
+    legacySourceLocation true
 }
diff --git a/v7/palette/build.gradle b/v7/palette/build.gradle
index 6da6914..25a60c7 100644
--- a/v7/palette/build.gradle
+++ b/v7/palette/build.gradle
@@ -1,4 +1,6 @@
-apply plugin: android.support.SupportAndroidLibraryPlugin
+plugins {
+    id("SupportAndroidLibraryPlugin")
+}
 
 dependencies {
     api project(':support-compat')
@@ -18,4 +20,5 @@
     publish true
     inceptionYear '2014'
     description 'Android Support Palette v7'
+    legacySourceLocation true
 }
diff --git a/v7/preference/build.gradle b/v7/preference/build.gradle
index 2b1e871..b5f7ac4 100644
--- a/v7/preference/build.gradle
+++ b/v7/preference/build.gradle
@@ -14,7 +14,9 @@
  * limitations under the License
  */
 
-apply plugin: android.support.SupportAndroidLibraryPlugin
+plugins {
+    id("SupportAndroidLibraryPlugin")
+}
 
 dependencies {
     api project(':support-v4')
@@ -54,4 +56,5 @@
     publish true
     inceptionYear '2015'
     description 'Android Support Preference v7'
+    legacySourceLocation true
 }
diff --git a/v7/recyclerview/build.gradle b/v7/recyclerview/build.gradle
index ad1150f..9799701 100644
--- a/v7/recyclerview/build.gradle
+++ b/v7/recyclerview/build.gradle
@@ -1,4 +1,6 @@
-apply plugin: android.support.SupportAndroidLibraryPlugin
+plugins {
+    id("SupportAndroidLibraryPlugin")
+}
 
 dependencies {
     api project(':support-annotations')
@@ -40,4 +42,5 @@
     publish true
     inceptionYear '2014'
     description 'Android Support RecyclerView v7'
+    legacySourceLocation true
 }
diff --git a/wear/build.gradle b/wear/build.gradle
index 814f5cf..6a7c903 100644
--- a/wear/build.gradle
+++ b/wear/build.gradle
@@ -1,4 +1,6 @@
-apply plugin: android.support.SupportAndroidLibraryPlugin
+plugins {
+    id("SupportAndroidLibraryPlugin")
+}
 
 dependencies {
     api project(':support-annotations')
@@ -42,4 +44,5 @@
         name 'The Apache Software License, Version 2.0'
         url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
     }
+    legacySourceLocation true
 }