Browse Source

For Android - refactor to remove buildscript block.

Yao Wei Tjong 姚伟忠 7 years ago
parent
commit
3db124b5cd

+ 2 - 2
android/launcher-app/build.gradle.kts

@@ -22,8 +22,8 @@
 
 plugins {
     id("com.android.application")
-    id("kotlin-android")
-    id("kotlin-android-extensions")
+    kotlin("android")
+    kotlin("android.extensions")
 }
 
 urhoAndroidModule()

+ 2 - 2
android/urho3d-lib/build.gradle.kts

@@ -25,8 +25,8 @@ import org.gradle.internal.os.OperatingSystem
 
 plugins {
     id("com.android.library")
-    id("kotlin-android")
-    id("kotlin-android-extensions")
+    kotlin("android")
+    kotlin("android.extensions")
     `maven-publish`
 }
 

+ 0 - 16
build.gradle.kts

@@ -24,22 +24,6 @@ plugins {
     base
 }
 
-buildscript {
-    var kotlinVersion: String by extra
-    kotlinVersion = "1.2.61"
-    repositories {
-        google()
-        jcenter()
-    }
-    dependencies {
-        classpath("com.android.tools.build:gradle:3.2.0-beta04")
-        classpath(kotlin("gradle-plugin", kotlinVersion))
-
-        // NOTE: Do not place your application dependencies here; they belong
-        // in the individual module build.gradle.kts files
-    }
-}
-
 allprojects {
     group = "com.github.urho3d"
     version = "1.8-SNAPSHOT"

+ 3 - 2
buildSrc/src/main/kotlin/UrhoCommon.kt

@@ -27,10 +27,11 @@ import org.gradle.kotlin.dsl.kotlin
 import org.gradle.kotlin.dsl.project
 import java.io.File
 
+const val androidToolsVersion = "3.2.0-beta04"
 const val kotlinVersion = "1.2.61"
 const val junitVersion = "4.12"
 const val testRunnerVersion = "1.0.2"
-const val testExpressoVersion = "3.0.2"
+const val testEspressoVersion = "3.0.2"
 
 /**
  * Prepare the module as Android Application with Urho3D AAR dependency.
@@ -52,7 +53,7 @@ fun DependencyHandlerScope.kotlinAndroidDependencies() {
     "implementation"(kotlin("stdlib-jdk8", kotlinVersion))
     "testImplementation"("junit:junit:$junitVersion")
     "androidTestImplementation"("com.android.support.test:runner:$testRunnerVersion")
-    "androidTestImplementation"("com.android.support.test.espresso:espresso-core:$testExpressoVersion")
+    "androidTestImplementation"("com.android.support.test.espresso:espresso-core:$testEspressoVersion")
 }
 
 /**

+ 18 - 0
settings.gradle.kts

@@ -23,4 +23,22 @@
 // See https://docs.gradle.org/current/userguide/publishing_maven.html#publishing_maven:deferred_configuration
 enableFeaturePreview("STABLE_PUBLISHING")
 
+pluginManagement {
+    repositories {
+        gradlePluginPortal()
+        google()
+        jcenter()
+    }
+    resolutionStrategy {
+        eachPlugin {
+            if (requested.id.id.startsWith("com.android.")) {
+                useModule("com.android.tools.build:gradle:$androidToolsVersion")
+            }
+            if (requested.id.id.startsWith("org.jetbrains.kotlin.")) {
+                useVersion(kotlinVersion)
+            }
+        }
+    }
+}
+
 include(":android:urho3d-lib", ":android:launcher-app")