Do not tell about Android compiler plugin in JPS in case of non-Android project

This commit is contained in:
Yan Zhulanow
2014-12-11 19:29:02 +03:00
parent 6ab2dc90f8
commit 09809d2f7a
@@ -33,15 +33,19 @@ public class KotlinAndroidJpsPlugin : KotlinJpsCompilerArgumentsProvider {
override fun getExtraArguments(moduleBuildTarget: ModuleBuildTarget, context: CompileContext): List<String> { override fun getExtraArguments(moduleBuildTarget: ModuleBuildTarget, context: CompileContext): List<String> {
val module = moduleBuildTarget.getModule() val module = moduleBuildTarget.getModule()
val pluginId = AndroidCommandLineProcessor.ANDROID_COMPILER_PLUGIN_ID val pluginId = AndroidCommandLineProcessor.ANDROID_COMPILER_PLUGIN_ID
return listOf( val resPath = getAndroidResPath(module)
getPluginOptionString(pluginId, AndroidCommandLineProcessor.RESOURCE_PATH_OPTION.name, getAndroidResPath(module)), val manifestFile = getAndroidManifest(module)
getPluginOptionString(pluginId, AndroidCommandLineProcessor.MANIFEST_FILE_OPTION.name, 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<String> { override fun getClasspath(moduleBuildTarget: ModuleBuildTarget, context: CompileContext): List<String> {
val inJar = PathUtil.getJarPathForClass(javaClass).isFile() val inJar = PathUtil.getJarPathForClass(javaClass).isFile()
return listOf( val manifestFile = getAndroidManifest(moduleBuildTarget.getModule())
return if (manifestFile != null) {
listOf(
if (inJar) { if (inJar) {
val libDirectory = PathUtil.getJarPathForClass(javaClass).getParentFile().getParentFile() val libDirectory = PathUtil.getJarPathForClass(javaClass).getParentFile().getParentFile()
File(libDirectory, jarFileName).getAbsolutePath() File(libDirectory, jarFileName).getAbsolutePath()
@@ -49,20 +53,21 @@ public class KotlinAndroidJpsPlugin : KotlinJpsCompilerArgumentsProvider {
// We're in tests now (in out/production/android-jps-plugin) // We're in tests now (in out/production/android-jps-plugin)
val kotlinProjectDirectory = PathUtil.getJarPathForClass(javaClass).getParentFile().getParentFile().getParentFile() val kotlinProjectDirectory = PathUtil.getJarPathForClass(javaClass).getParentFile().getParentFile().getParentFile()
File(kotlinProjectDirectory, "dist/kotlinc/lib/$jarFileName").getAbsolutePath() 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) val extension = AndroidJpsUtil.getExtension(module)
if (extension == null) return "" if (extension == null) return null
val path = AndroidJpsUtil.getResourceDirForCompilationPath(extension) val path = AndroidJpsUtil.getResourceDirForCompilationPath(extension)
return File(path!!.getAbsolutePath() + "/layout").getAbsolutePath() return File(path!!.getAbsolutePath() + "/layout").getAbsolutePath()
} }
private fun getAndroidManifest(module: JpsModule): String { private fun getAndroidManifest(module: JpsModule): String? {
val extension = AndroidJpsUtil.getExtension(module) val extension = AndroidJpsUtil.getExtension(module)
if (extension == null) return "" if (extension == null) return null
return AndroidJpsUtil.getManifestFileForCompilationPath(extension)!!.getAbsolutePath() return AndroidJpsUtil.getManifestFileForCompilationPath(extension)!!.getAbsolutePath()
} }
} }