CLI: Allow to specify JDK for classpath building with '-jdk' compiler argument.
Maven: support jdk parameter linked to kotlin.compiler.jdk property. Gradle: support jdk compiler option.
This commit is contained in:
+5
-1
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010-2015 JetBrains s.r.o.
|
||||
* Copyright 2010-2016 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.
|
||||
@@ -31,6 +31,10 @@ public class K2JVMCompilerArguments extends CommonCompilerArguments {
|
||||
@Argument(value = "include-runtime", description = "Include Kotlin runtime in to resulting .jar")
|
||||
public boolean includeRuntime;
|
||||
|
||||
@Argument(value = "jdk", description = "Path to JDK home to include into classpath, if differs from default %JAVA_HOME%")
|
||||
@ValueDescription("<path>")
|
||||
public String jdk;
|
||||
|
||||
@Argument(value = "no-jdk", description = "Don't include Java runtime into classpath")
|
||||
public boolean noJdk;
|
||||
|
||||
|
||||
@@ -62,7 +62,19 @@ class K2JVMCompiler : CLICompiler<K2JVMCompilerArguments>() {
|
||||
|
||||
try {
|
||||
if (!arguments.noJdk) {
|
||||
configuration.addJvmClasspathRoots(PathUtil.getJdkClassesRoots())
|
||||
if (arguments.jdk != null) {
|
||||
configuration.addJvmClasspathRoots(PathUtil.getJdkClassesRoots(File(arguments.jdk)))
|
||||
}
|
||||
else {
|
||||
configuration.addJvmClasspathRoots(PathUtil.getJdkClassesRoots())
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (arguments.jdk != null) {
|
||||
messageCollector.report(CompilerMessageSeverity.WARNING,
|
||||
"The '-jdk' option with a path to JDK is ignored because '-no-jdk' is specified",
|
||||
CompilerMessageLocation.NO_LOCATION)
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (t: Throwable) {
|
||||
|
||||
Reference in New Issue
Block a user