From 923fbaaca6312ed1c6c4986484e1a20739e07640 Mon Sep 17 00:00:00 2001 From: Yan Zhulanow Date: Tue, 24 Apr 2018 16:15:50 +0300 Subject: [PATCH] Pill: Fix launching debuggable Android Studio on 'as' bunches --- buildSrc/src/main/kotlin/pill/plugin.kt | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/buildSrc/src/main/kotlin/pill/plugin.kt b/buildSrc/src/main/kotlin/pill/plugin.kt index 89d2e2777e5..22074ca638c 100644 --- a/buildSrc/src/main/kotlin/pill/plugin.kt +++ b/buildSrc/src/main/kotlin/pill/plugin.kt @@ -222,8 +222,9 @@ class JpsCompatiblePlugin : Plugin { .map { it.trim() } .filter { it.isNotEmpty() } - fun addOrReplaceOptionValue(name: String, value: Any) { - options = options.filter { !it.startsWith("-D$name=") } + listOf("-D$name=$value") + fun addOrReplaceOptionValue(name: String, value: Any?) { + val optionsWithoutNewValue = options.filter { !it.startsWith("-D$name=") } + options = if (value == null) optionsWithoutNewValue else (optionsWithoutNewValue + listOf("-D$name=$value")) } val robolectricClasspath = project.rootProject @@ -236,6 +237,9 @@ class JpsCompatiblePlugin : Plugin { addOrReplaceOptionValue("robolectric.classpath", robolectricClasspath) addOrReplaceOptionValue("use.pill", "true") + val isAndroidStudioBunch = project.findProperty("versions.androidStudioRelease") != null + addOrReplaceOptionValue("idea.platform.prefix", if (isAndroidStudioBunch) "AndroidStudio" else null) + val androidJarPath = project.configurations.findByName("androidJar")?.singleFile val androidSdkPath = project.configurations.findByName("androidSdk")?.singleFile