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,36 +33,41 @@ 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())
if (inJar) { return if (manifestFile != null) {
val libDirectory = PathUtil.getJarPathForClass(javaClass).getParentFile().getParentFile() listOf(
File(libDirectory, jarFileName).getAbsolutePath() if (inJar) {
} else { val libDirectory = PathUtil.getJarPathForClass(javaClass).getParentFile().getParentFile()
// We're in tests now (in out/production/android-jps-plugin) File(libDirectory, jarFileName).getAbsolutePath()
val kotlinProjectDirectory = PathUtil.getJarPathForClass(javaClass).getParentFile().getParentFile().getParentFile() } else {
File(kotlinProjectDirectory, "dist/kotlinc/lib/$jarFileName").getAbsolutePath() // 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) 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()
} }
} }