Add system property/environment var for -kotlin-home compiler option
This commit is contained in:
@@ -49,6 +49,10 @@ import static org.jetbrains.kotlin.cli.common.environment.UtilKt.setIdeaIoUseFal
|
|||||||
import static org.jetbrains.kotlin.cli.common.messages.CompilerMessageSeverity.*;
|
import static org.jetbrains.kotlin.cli.common.messages.CompilerMessageSeverity.*;
|
||||||
|
|
||||||
public abstract class CLICompiler<A extends CommonCompilerArguments> extends CLITool<A> {
|
public abstract class CLICompiler<A extends CommonCompilerArguments> extends CLITool<A> {
|
||||||
|
|
||||||
|
public static String KOTLIN_HOME_PROPERTY = "kotlin.home";
|
||||||
|
public static String KOTLIN_HOME_ENV_VAR = "KOTLIN_HOME";
|
||||||
|
|
||||||
// Used in CompilerRunnerUtil#invokeExecMethod, in Eclipse plugin (KotlinCLICompiler) and in kotlin-gradle-plugin (GradleCompilerRunner)
|
// Used in CompilerRunnerUtil#invokeExecMethod, in Eclipse plugin (KotlinCLICompiler) and in kotlin-gradle-plugin (GradleCompilerRunner)
|
||||||
@NotNull
|
@NotNull
|
||||||
public ExitCode execAndOutputXml(@NotNull PrintStream errStream, @NotNull Services services, @NotNull String... args) {
|
public ExitCode execAndOutputXml(@NotNull PrintStream errStream, @NotNull Services services, @NotNull String... args) {
|
||||||
@@ -210,8 +214,14 @@ public abstract class CLICompiler<A extends CommonCompilerArguments> extends CLI
|
|||||||
@Nullable
|
@Nullable
|
||||||
private static KotlinPaths computeKotlinPaths(@NotNull MessageCollector messageCollector, @NotNull CommonCompilerArguments arguments) {
|
private static KotlinPaths computeKotlinPaths(@NotNull MessageCollector messageCollector, @NotNull CommonCompilerArguments arguments) {
|
||||||
KotlinPaths paths;
|
KotlinPaths paths;
|
||||||
if (arguments.getKotlinHome() != null) {
|
String kotlinHomeProperty = System.getProperty(KOTLIN_HOME_PROPERTY);
|
||||||
File kotlinHome = new File(arguments.getKotlinHome());
|
String kotlinHomeEnvVar = System.getenv(KOTLIN_HOME_ENV_VAR);
|
||||||
|
File kotlinHome =
|
||||||
|
arguments.getKotlinHome() != null ? new File(arguments.getKotlinHome()) :
|
||||||
|
kotlinHomeProperty != null ? new File(kotlinHomeProperty) :
|
||||||
|
kotlinHomeEnvVar != null ? new File(kotlinHomeEnvVar)
|
||||||
|
: null;
|
||||||
|
if (kotlinHome != null) {
|
||||||
if (kotlinHome.isDirectory()) {
|
if (kotlinHome.isDirectory()) {
|
||||||
paths = new KotlinPathsFromHomeDir(kotlinHome);
|
paths = new KotlinPathsFromHomeDir(kotlinHome);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user