From cc2b244484ddb2ddf7578a8f80fea4ecd25f2715 Mon Sep 17 00:00:00 2001 From: Ilya Chernikov Date: Thu, 5 Apr 2018 21:41:33 +0200 Subject: [PATCH] Add a compiler option to disable default scripting plugin --- .../kotlin/cli/common/arguments/K2JVMCompilerArguments.kt | 3 +++ .../cli/src/org/jetbrains/kotlin/cli/jvm/K2JVMCompiler.kt | 5 ++++- compiler/testData/cli/jvm/extraHelp.out | 2 ++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/K2JVMCompilerArguments.kt b/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/K2JVMCompilerArguments.kt index 5b9043a149c..a9c0995b1b3 100644 --- a/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/K2JVMCompilerArguments.kt +++ b/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/K2JVMCompilerArguments.kt @@ -231,6 +231,9 @@ class K2JVMCompilerArguments : CommonCompilerArguments() { @Argument(value = "-Xenable-jvm-default", description = "Allow to use '@JvmDefault' for JVM default method support") var enableJvmDefault: Boolean by FreezableVar(false) + @Argument(value = "-Xdisable-default-scripting-plugin", description = "Do not enable scripting plugin by default") + var disableDefaultScriptingPlugin: Boolean by FreezableVar(false) + // Paths to output directories for friend modules. var friendPaths: Array? by FreezableVar(null) 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 af61f6d93ff..43f1259d56b 100644 --- a/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/K2JVMCompiler.kt +++ b/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/K2JVMCompiler.kt @@ -232,7 +232,10 @@ class K2JVMCompiler : CLICompiler() { true } - if (!isEmbeddable && pluginClasspaths.none { File(it).name == PathUtil.KOTLIN_SCRIPTING_COMPILER_PLUGIN_JAR }) { + if (!isEmbeddable && + pluginClasspaths.none { File(it).name == PathUtil.KOTLIN_SCRIPTING_COMPILER_PLUGIN_JAR } && + !arguments.disableDefaultScriptingPlugin + ) { // if scripting plugin is not enabled explicitly (probably from another path) try to enable it implicitly val libPath = paths?.libPath ?: File(".") val pluginJar = File(libPath, PathUtil.KOTLIN_SCRIPTING_COMPILER_PLUGIN_JAR) diff --git a/compiler/testData/cli/jvm/extraHelp.out b/compiler/testData/cli/jvm/extraHelp.out index 0094b35194a..65815cf0449 100644 --- a/compiler/testData/cli/jvm/extraHelp.out +++ b/compiler/testData/cli/jvm/extraHelp.out @@ -9,6 +9,8 @@ where advanced options include: Normalize constructor calls (disable: don't normalize; enable: normalize), default is disable -Xdump-declarations-to= Path to JSON file to dump Java to Kotlin declaration mappings -Xenable-jvm-default Allow to use '@JvmDefault' for JVM default method support + -Xdisable-default-scripting-plugin + Do not enable scripting plugin by default -Xmultifile-parts-inherit Compile multifile classes as a hierarchy of parts and facade -Xmodule-path= Paths where to find Java 9+ modules -Xjavac-arguments= Java compiler arguments