From 09809d2f7a0e0ed7563b5f1cc576925de71aa8b0 Mon Sep 17 00:00:00 2001 From: Yan Zhulanow Date: Thu, 11 Dec 2014 19:29:02 +0300 Subject: [PATCH] Do not tell about Android compiler plugin in JPS in case of non-Android project --- .../src/KotlinAndroidJpsPlugin.kt | 41 +++++++++++-------- 1 file changed, 23 insertions(+), 18 deletions(-) diff --git a/plugins/android-jps-plugin/src/KotlinAndroidJpsPlugin.kt b/plugins/android-jps-plugin/src/KotlinAndroidJpsPlugin.kt index b02c9135c7d..274f0a29803 100644 --- a/plugins/android-jps-plugin/src/KotlinAndroidJpsPlugin.kt +++ b/plugins/android-jps-plugin/src/KotlinAndroidJpsPlugin.kt @@ -33,36 +33,41 @@ public class KotlinAndroidJpsPlugin : KotlinJpsCompilerArgumentsProvider { override fun getExtraArguments(moduleBuildTarget: ModuleBuildTarget, context: CompileContext): List { val module = moduleBuildTarget.getModule() val pluginId = AndroidCommandLineProcessor.ANDROID_COMPILER_PLUGIN_ID - return listOf( - getPluginOptionString(pluginId, AndroidCommandLineProcessor.RESOURCE_PATH_OPTION.name, getAndroidResPath(module)), - getPluginOptionString(pluginId, AndroidCommandLineProcessor.MANIFEST_FILE_OPTION.name, getAndroidManifest(module)) - ) + val resPath = getAndroidResPath(module) + val manifestFile = getAndroidManifest(module) + return if (resPath != null && manifestFile != null) listOf( + getPluginOptionString(pluginId, AndroidCommandLineProcessor.RESOURCE_PATH_OPTION.name, resPath), + getPluginOptionString(pluginId, AndroidCommandLineProcessor.MANIFEST_FILE_OPTION.name, manifestFile)) + else listOf() } override fun getClasspath(moduleBuildTarget: ModuleBuildTarget, context: CompileContext): List { val inJar = PathUtil.getJarPathForClass(javaClass).isFile() - return listOf( - if (inJar) { - val libDirectory = PathUtil.getJarPathForClass(javaClass).getParentFile().getParentFile() - File(libDirectory, jarFileName).getAbsolutePath() - } else { - // We're in tests now (in out/production/android-jps-plugin) - val kotlinProjectDirectory = PathUtil.getJarPathForClass(javaClass).getParentFile().getParentFile().getParentFile() - File(kotlinProjectDirectory, "dist/kotlinc/lib/$jarFileName").getAbsolutePath() - } - ) + val manifestFile = getAndroidManifest(moduleBuildTarget.getModule()) + return if (manifestFile != null) { + listOf( + if (inJar) { + val libDirectory = PathUtil.getJarPathForClass(javaClass).getParentFile().getParentFile() + File(libDirectory, jarFileName).getAbsolutePath() + } else { + // We're in tests now (in out/production/android-jps-plugin) + val kotlinProjectDirectory = PathUtil.getJarPathForClass(javaClass).getParentFile().getParentFile().getParentFile() + File(kotlinProjectDirectory, "dist/kotlinc/lib/$jarFileName").getAbsolutePath() + }) + } + else listOf() } - private fun getAndroidResPath(module: JpsModule): String { + private fun getAndroidResPath(module: JpsModule): String? { val extension = AndroidJpsUtil.getExtension(module) - if (extension == null) return "" + if (extension == null) return null val path = AndroidJpsUtil.getResourceDirForCompilationPath(extension) return File(path!!.getAbsolutePath() + "/layout").getAbsolutePath() } - private fun getAndroidManifest(module: JpsModule): String { + private fun getAndroidManifest(module: JpsModule): String? { val extension = AndroidJpsUtil.getExtension(module) - if (extension == null) return "" + if (extension == null) return null return AndroidJpsUtil.getManifestFileForCompilationPath(extension)!!.getAbsolutePath() } } \ No newline at end of file