diff --git a/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/K2JVMCompilerArguments.java b/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/K2JVMCompilerArguments.java index 509156005b0..7a8dfb1c856 100644 --- a/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/K2JVMCompilerArguments.java +++ b/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/K2JVMCompilerArguments.java @@ -51,6 +51,10 @@ public class K2JVMCompilerArguments extends CommonCompilerArguments { @Argument(value = "module-name", description = "Module name") public String moduleName; + @Argument(value = "jvm-target", description = "Compile code to specified JVM target: 1.6 or 1.8. Default one is 1.6.") + @ValueDescription("<1.6|1.8>") + public String jvmTarget; + // Advanced options @Argument(value = "Xno-call-assertions", description = "Don't generate not-null assertion after each invocation of method returning not-null") public boolean noCallAssertions; diff --git a/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/K2JVMCompiler.kt b/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/K2JVMCompiler.kt index 659d1b35292..efe3ad7074b 100644 --- a/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/K2JVMCompiler.kt +++ b/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/K2JVMCompiler.kt @@ -128,6 +128,9 @@ class K2JVMCompiler : CLICompiler() { if (friendPaths != null) { configuration.put(JVMConfigurationKeys.FRIEND_PATHS, friendPaths) } + if ("1.8".equals(arguments.jvmTarget)) { + configuration.put(JVMConfigurationKeys.JVM_8_TARGET, true) + } putAdvancedOptions(configuration, arguments) diff --git a/compiler/testData/cli/jvm/help.out b/compiler/testData/cli/jvm/help.out index 189753914cf..bf02da0247a 100644 --- a/compiler/testData/cli/jvm/help.out +++ b/compiler/testData/cli/jvm/help.out @@ -9,6 +9,7 @@ where possible options include: -script Evaluate the script file -kotlin-home Path to Kotlin compiler home directory, used for runtime libraries discovery -module-name Module name + -jvm-target <1.6|1.8> Compile code to specified JVM target: 1.6 or 1.8. Default one is 1.6. -language-version Provide source compatibility with specified language version -nowarn Generate no warnings -verbose Enable verbose logging output diff --git a/compiler/testData/cli/jvm/wrongArgument.out b/compiler/testData/cli/jvm/wrongArgument.out index cfb330128ca..d3a735e2d9a 100644 --- a/compiler/testData/cli/jvm/wrongArgument.out +++ b/compiler/testData/cli/jvm/wrongArgument.out @@ -10,6 +10,7 @@ where possible options include: -script Evaluate the script file -kotlin-home Path to Kotlin compiler home directory, used for runtime libraries discovery -module-name Module name + -jvm-target <1.6|1.8> Compile code to specified JVM target: 1.6 or 1.8. Default one is 1.6. -language-version Provide source compatibility with specified language version -nowarn Generate no warnings -verbose Enable verbose logging output