add compiler key for providing android resources path

This commit is contained in:
Mikhail Mutcianko
2014-07-17 14:23:41 +04:00
committed by Yan Zhulanow
parent afee95a37c
commit ec6f9c9fc5
6 changed files with 21 additions and 3 deletions
@@ -66,6 +66,10 @@ public class K2JVMCompilerArguments extends CommonCompilerArguments {
@Argument(value = "Xno-optimize", description = "Disable optimizations")
public boolean noOptimize;
@Argument(value = "androidRes", description = "Android resources path")
@ValueDescription("<path>")
public String androidRes;
@Override
@NotNull
public String executableScriptFileName() {
+2 -1
View File
@@ -19,5 +19,6 @@
<orderEntry type="module" module-name="serialization" />
<orderEntry type="module" module-name="serialization.jvm" />
<orderEntry type="module" module-name="util" />
<orderEntry type="module" module-name="frontend.android" />
</component>
</module>
</module>
@@ -51,4 +51,7 @@ public class JVMConfigurationKeys {
public static final CompilerConfigurationKey<List<String>> MODULE_IDS =
CompilerConfigurationKey.create("module id strings");
public static final CompilerConfigurationKey<String> ANDROID_RES_PATH =
CompilerConfigurationKey.create("android resources search path");
}
@@ -90,6 +90,10 @@ public class K2JVMCompiler extends CLICompiler<K2JVMCompilerArguments> {
return INTERNAL_ERROR;
}
if (arguments.androidRes != null) {
configuration.put(JVMConfigurationKeys.ANDROID_RES_PATH, arguments.androidRes);
}
if (arguments.script) {
if (arguments.freeArgs.isEmpty()) {
messageCollector.report(CompilerMessageSeverity.ERROR, "Specify script source path to evaluate",
@@ -56,6 +56,8 @@ import kotlin.Function1;
import kotlin.Unit;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.TestOnly;
import org.jetbrains.jet.lang.resolve.android.AndroidUIXmlPathProvider;
import org.jetbrains.jet.lang.resolve.android.CliAndroidUIXmlPathProvider;
import org.jetbrains.kotlin.asJava.JavaElementFinder;
import org.jetbrains.kotlin.asJava.KotlinLightClassForPackage;
import org.jetbrains.kotlin.asJava.LightClassGenerationSupport;
@@ -293,6 +295,9 @@ public class JetCoreEnvironment {
configuration.getList(CommonConfigurationKeys.SCRIPT_DEFINITIONS_KEY)
);
String s = configuration.get(JVMConfigurationKeys.ANDROID_RES_PATH);
project.registerService(AndroidUIXmlPathProvider.class, new CliAndroidUIXmlPathProvider(s));
project.registerService(VirtualFileFinderFactory.class, new CliVirtualFileFinderFactory(classPath));
}
@@ -1,11 +1,12 @@
package org.jetbrains.jet.lang.resolve.android
import java.io.File
import java.util.ArrayList
class CliAndroidUIXmlPathProvider: AndroidUIXmlPathProvider {
class CliAndroidUIXmlPathProvider(val searchPath: String?): AndroidUIXmlPathProvider {
override fun getPaths(): MutableCollection<File> {
throw UnsupportedOperationException()
return if (searchPath != null) arrayListOf(File(searchPath + "/layout/")) else ArrayList()
}
}