From a4b21f3b0867b1c9503b2783a72418f33401bb5e Mon Sep 17 00:00:00 2001 From: Yan Zhulanow Date: Thu, 22 Dec 2016 15:13:50 +0300 Subject: [PATCH] Android Gradle plugin: Fix compatibility with Android Studio 2.3 (KT-15376) --- .../android/AndroidGradleWrapper.groovy | 23 +++++++++++-------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/plugin/android/AndroidGradleWrapper.groovy b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/plugin/android/AndroidGradleWrapper.groovy index f42ca53710f..2aef9cc0f23 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/plugin/android/AndroidGradleWrapper.groovy +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/plugin/android/AndroidGradleWrapper.groovy @@ -197,13 +197,8 @@ class AndroidGradleWrapper { if (libraries == null) return jarToLibraryArtifactMap for (lib in libraries) { - if (lib.class.name == "com.android.builder.dependency.level2.AndroidDependency") { - // android tools >= 2.3 - jarToLibraryArtifactMap[lib.jarFile] = lib.artifactFile - } else { - // android tools <= 2.2 - jarToLibraryArtifactMap[lib.jarFile] = lib.bundle - } + Object bundle = getLibraryArtifactFile(lib) + jarToLibraryArtifactMap[lib.jarFile] = bundle // local dependencies are detected as changed by gradle, because they are seem to be // rewritten every time when bundle changes @@ -211,11 +206,11 @@ class AndroidGradleWrapper { for (localDep in lib.localJars) { if (localDep instanceof File) { // android tools 2.2 - jarToLibraryArtifactMap[localDep] = lib.bundle + jarToLibraryArtifactMap[localDep] = bundle } else if (localDep.metaClass.getMetaMethod("jarFile") != null) { // android tools < 2.2 - jarToLibraryArtifactMap[localDep.jarFile] = lib.bundle + jarToLibraryArtifactMap[localDep.jarFile] = bundle } } } @@ -223,6 +218,16 @@ class AndroidGradleWrapper { return jarToLibraryArtifactMap } + private static def getLibraryArtifactFile(Object lib) { + if (lib.class.name == "com.android.builder.dependency.level2.AndroidDependency") { + // android tools >= 2.3 + return lib.artifactFile + } else { + // android tools <= 2.2 + return lib.bundle + } + } + @Nullable private static Iterable getVariantLibraryDependencies(BaseVariantData variantData) { def variantDependency = variantData.variantDependency