Logic related to command-line options moved to android-compiler-plugin

This commit is contained in:
Andrey Breslav
2014-09-23 18:23:39 +04:00
committed by Yan Zhulanow
parent febfdde89e
commit 1e70369cf8
11 changed files with 152 additions and 32 deletions
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="module" module-name="jps-plugin" scope="PROVIDED" />
<orderEntry type="library" scope="PROVIDED" name="jps" level="project" />
<orderEntry type="library" scope="PROVIDED" name="android" level="project" />
<orderEntry type="library" name="kotlin-runtime" level="project" />
<orderEntry type="module" module-name="android-compiler-plugin" />
</component>
</module>
@@ -0,0 +1,53 @@
/*
* Copyright 2010-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jetbrains.kotlin.android.jps
import org.jetbrains.jet.jps.build.KotlinJpsCompilerArgumentsProvider
import org.jetbrains.jps.incremental.ModuleBuildTarget
import org.jetbrains.jps.incremental.CompileContext
import org.jetbrains.jps.model.module.JpsModule
import java.io.File
import org.jetbrains.jps.android.AndroidJpsUtil
import org.jetbrains.kotlin.android.AndroidCommandLineProcessor
import org.jetbrains.kotlin.compiler.plugin.CliOption
public class KotlinAndroidJpsPlugin : KotlinJpsCompilerArgumentsProvider {
override fun getExtraArguments(moduleBuildTarget: ModuleBuildTarget, context: CompileContext): List<String> {
val module = moduleBuildTarget.getModule()
return listOf(
makePluginOption(AndroidCommandLineProcessor.RESOURCE_PATH_OPTION, getAndroidResPath(module)),
makePluginOption(AndroidCommandLineProcessor.MANIFEST_FILE_OPTION, getAndroidManifest(module))
)
}
private fun makePluginOption(option: CliOption, value: String): String {
return "plugin:${AndroidCommandLineProcessor.ANDROID_COMPILER_PLUGIN_ID}:${option.name}=$value"
}
private fun getAndroidResPath(module: JpsModule): String {
val extension = AndroidJpsUtil.getExtension(module)
if (extension == null) return ""
val path = AndroidJpsUtil.getResourceDirForCompilationPath(extension)
return File(path!!.getAbsolutePath() + "/layout").getAbsolutePath()
}
private fun getAndroidManifest(module: JpsModule): String {
val extension = AndroidJpsUtil.getExtension(module)
if (extension == null) return ""
return AndroidJpsUtil.getManifestFileForCompilationPath(extension)!!.getAbsolutePath()
}
}
@@ -0,0 +1 @@
org.jetbrains.kotlin.android.jps.KotlinAndroidJpsPlugin