Add kotlin to buildSrc

Test: ./gradlew createArchive
Change-Id: I8008df712adce884b022ee75343b38d52895717e
(cherry picked from commit 6aa53caa4aafa737248511e64e32342bd88a0635)
diff --git a/app-toolkit/build.gradle b/app-toolkit/build.gradle
index 155a836..9bcb827 100644
--- a/app-toolkit/build.gradle
+++ b/app-toolkit/build.gradle
@@ -18,10 +18,11 @@
     ext.supportRootFolder = new File(project.projectDir, "../")
     apply from: 'buildSrc/repos.gradle'
     apply from: 'init.gradle'
+    apply from: "buildSrc/build_dependencies.gradle"
     repos.addMavenRepositories(repositories)
     dependencies {
-        classpath libs.jacoco
-        classpath libs.gradle
-        classpath libs.kotlin.gradle_plugin
+        classpath build_libs.jacoco
+        classpath build_libs.gradle
+        classpath build_libs.kotlin.gradle_plugin
     }
 }
diff --git a/app-toolkit/dependencies.gradle b/app-toolkit/dependencies.gradle
index cb68089..31fc2ae 100644
--- a/app-toolkit/dependencies.gradle
+++ b/app-toolkit/dependencies.gradle
@@ -42,7 +42,6 @@
 
 ffLibs.kotlin = [
         stdlib : "org.jetbrains.kotlin:kotlin-stdlib:$ffVersions.kotlin",
-        gradle_plugin : "org.jetbrains.kotlin:kotlin-gradle-plugin:$ffVersions.kotlin"
 ]
 ffLibs.auto_common = "com.google.auto:auto-common:$ffVersions.auto_common"
 ffLibs.apache = [
diff --git a/build.gradle b/build.gradle
index 8c32175..ec83da5 100644
--- a/build.gradle
+++ b/build.gradle
@@ -17,14 +17,14 @@
 buildscript {
     ext.supportRootFolder = project.projectDir
     apply from: 'buildSrc/repos.gradle'
-
     apply from: 'buildSrc/init.gradle'
+    apply from: 'buildSrc/build_dependencies.gradle'
     init.setSdkInLocalPropertiesFile()
     repos.addMavenRepositories(repositories)
 
     dependencies {
-        classpath libs.gradle
-        classpath libs.jacoco
+        classpath build_libs.gradle
+        classpath build_libs.jacoco
     }
 }
 
diff --git a/buildSrc/build.gradle b/buildSrc/build.gradle
index 9f648d9..9c0d8af 100644
--- a/buildSrc/build.gradle
+++ b/buildSrc/build.gradle
@@ -1,17 +1,37 @@
-apply plugin: 'groovy'
-apply plugin: 'java'
+buildscript {
+    def supportRootFolder = project.projectDir.getParentFile()
+    repositories {
+        maven {
+            url "${supportRootFolder}/../../prebuilts/tools/common/m2/repository"
+        }
+    }
 
-apply from: "dependencies.gradle"
+    apply from: "build_dependencies.gradle"
+
+    dependencies {
+        classpath build_libs.kotlin.gradle_plugin
+    }
+}
+
+apply from: "build_dependencies.gradle"
 
 ext.supportRootFolder = project.projectDir.getParentFile()
 apply from: 'repos.gradle'
 
 repos.addMavenRepositories(repositories)
 
+apply plugin: 'groovy'
+apply plugin: 'java'
+apply plugin: 'kotlin'
+
+compileGroovy {
+    dependsOn tasks.getByPath('compileKotlin')
+    classpath += files(compileKotlin.destinationDir)
+}
 dependencies {
-    compile libs.gradle
-    compile libs.jacoco
-    compile libs.error_prone
-    compile libs.jarjar_gradle
+    compile build_libs.gradle
+    compile build_libs.jacoco
+    compile build_libs.error_prone
+    compile build_libs.jarjar_gradle
     compile gradleApi()
 }
diff --git a/buildSrc/build_dependencies.gradle b/buildSrc/build_dependencies.gradle
new file mode 100644
index 0000000..b7a5049
--- /dev/null
+++ b/buildSrc/build_dependencies.gradle
@@ -0,0 +1,34 @@
+/*
+ * Copyright 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.
+ */
+
+def build_libs = [:]
+
+def androidPluginVersionOverride = System.getenv("GRADLE_PLUGIN_VERSION")
+
+if (androidPluginVersionOverride != null) {
+    build_libs.gradle = 'com.android.tools.build:gradle:' + androidPluginVersionOverride
+} else {
+    // Keep gradle plugin version in sync with ub_supportlib-master manifest.
+    build_libs.gradle = 'com.android.tools.build:gradle:3.0.0'
+}
+
+// jarjar plugin
+build_libs.jarjar_gradle = 'org.anarres.jarjar:jarjar-gradle:1.0.0'
+build_libs.error_prone = 'net.ltgt.gradle:gradle-errorprone-plugin:0.0.10'
+build_libs.jacoco = 'org.jacoco:org.jacoco.core:0.7.8'
+build_libs.kotlin = [gradle_plugin: "org.jetbrains.kotlin:kotlin-gradle-plugin:1.1.3"]
+
+rootProject.ext['build_libs'] = build_libs
diff --git a/buildSrc/dependencies.gradle b/buildSrc/dependencies.gradle
index 05aac07..b61cfc6 100644
--- a/buildSrc/dependencies.gradle
+++ b/buildSrc/dependencies.gradle
@@ -24,16 +24,6 @@
 libs.test_rules = 'com.android.support.test:rules:1.0.1'
 libs.espresso_core = 'com.android.support.test.espresso:espresso-core:3.0.1'
 libs.espresso_contrib = 'com.android.support.test.espresso:espresso-contrib:3.0.1'
-libs.jacoco = 'org.jacoco:org.jacoco.core:0.7.8'
-
-def androidPluginVersionOverride = System.getenv("GRADLE_PLUGIN_VERSION")
-
-if (androidPluginVersionOverride != null) {
-    libs.gradle = 'com.android.tools.build:gradle:' + androidPluginVersionOverride
-} else {
-    // Keep gradle plugin version in sync with ub_supportlib-master manifest.
-    libs.gradle = 'com.android.tools.build:gradle:3.0.0'
-}
 
 //arch components
 libs.arch_lifecycle_runtime = "android.arch.lifecycle:runtime:1.0.3@aar"
@@ -41,9 +31,5 @@
 // Other dependencies
 libs.xml_parser_apis = 'xerces:xmlParserAPIs:2.6.2'
 libs.xerces_impl = 'xerces:xercesImpl:2.6.2'
-libs.error_prone = 'net.ltgt.gradle:gradle-errorprone-plugin:0.0.10'
-
-// jarjar plugin
-libs.jarjar_gradle = 'org.anarres.jarjar:jarjar-gradle:1.0.0'
 
 rootProject.ext['libs'] = libs
diff --git a/buildSrc/src/main/groovy/android/support/SupportAndroidLibraryPlugin.groovy b/buildSrc/src/main/groovy/android/support/SupportAndroidLibraryPlugin.groovy
index c40a8be..6f1288e 100644
--- a/buildSrc/src/main/groovy/android/support/SupportAndroidLibraryPlugin.groovy
+++ b/buildSrc/src/main/groovy/android/support/SupportAndroidLibraryPlugin.groovy
@@ -38,6 +38,8 @@
 
     @Override
     public void apply(Project project) {
+        KotlinNoOp noOp = new KotlinNoOp()
+        noOp.noOp()
         SupportLibraryExtension supportLibraryExtension =
                 project.extensions.create("supportLibrary", SupportLibraryExtension, project);
         SupportLibraryMavenUploader.apply(project, supportLibraryExtension);
diff --git a/buildSrc/src/main/kotlin/android/support/KotlinNoOp.kt b/buildSrc/src/main/kotlin/android/support/KotlinNoOp.kt
new file mode 100644
index 0000000..968f6ca
--- /dev/null
+++ b/buildSrc/src/main/kotlin/android/support/KotlinNoOp.kt
@@ -0,0 +1,24 @@
+/*
+ * Copyright 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
+
+class KotlinNoOp {
+
+    fun noOp() {
+    }
+
+}
\ No newline at end of file