From 33a8843d3432c7187195766875cea7f5378806e1 Mon Sep 17 00:00:00 2001 From: Yan Zhulanow Date: Mon, 23 Apr 2018 22:02:08 +0300 Subject: [PATCH] Pill: Download Android jars only if pill.android.tests option is set --- buildSrc/src/main/kotlin/pill/plugin.kt | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/buildSrc/src/main/kotlin/pill/plugin.kt b/buildSrc/src/main/kotlin/pill/plugin.kt index c479b09857a..89d2e2777e5 100644 --- a/buildSrc/src/main/kotlin/pill/plugin.kt +++ b/buildSrc/src/main/kotlin/pill/plugin.kt @@ -80,8 +80,11 @@ class JpsCompatiblePlugin : Plugin { if (project == project.rootProject) { project.tasks.create("pill") { doLast { pill(project) } - TaskUtils.useAndroidSdk(this) - TaskUtils.useAndroidJar(this) + + if (System.getProperty("pill.android.tests", "false") == "true") { + TaskUtils.useAndroidSdk(this) + TaskUtils.useAndroidJar(this) + } } project.tasks.create("unpill") { @@ -228,16 +231,18 @@ class JpsCompatiblePlugin : Plugin { .configurations.getByName("robolectricClasspath") .files.joinToString(File.pathSeparator) - val androidJarPath = project.configurations.getByName("androidJar").singleFile - val androidSdkPath = project.configurations.getByName("androidSdk").singleFile - addOrReplaceOptionValue("idea.home.path", platformDirProjectRelative) addOrReplaceOptionValue("ideaSdk.androidPlugin.path", platformDirProjectRelative + "/plugins/android/lib") addOrReplaceOptionValue("robolectric.classpath", robolectricClasspath) addOrReplaceOptionValue("use.pill", "true") - addOrReplaceOptionValue("android.sdk", "\$PROJECT_DIR\$/" + androidSdkPath.toRelativeString(projectDir)) - addOrReplaceOptionValue("android.jar", "\$PROJECT_DIR\$/" + androidJarPath.toRelativeString(projectDir)) + val androidJarPath = project.configurations.findByName("androidJar")?.singleFile + val androidSdkPath = project.configurations.findByName("androidSdk")?.singleFile + + if (androidJarPath != null && androidSdkPath != null) { + addOrReplaceOptionValue("android.sdk", "\$PROJECT_DIR\$/" + androidSdkPath.toRelativeString(projectDir)) + addOrReplaceOptionValue("android.jar", "\$PROJECT_DIR\$/" + androidJarPath.toRelativeString(projectDir)) + } vmParams.setAttribute("value", options.joinToString(" ")) }