[CLI] Make -Xcompiler-plugin experimental and K2 only
This commit is contained in:
committed by
teamcity
parent
928416c9c5
commit
b2e558a174
@@ -26,9 +26,7 @@ import org.jetbrains.kotlin.cli.common.ExitCode.*
|
|||||||
import org.jetbrains.kotlin.cli.common.arguments.CommonCompilerArguments
|
import org.jetbrains.kotlin.cli.common.arguments.CommonCompilerArguments
|
||||||
import org.jetbrains.kotlin.cli.common.environment.setIdeaIoUseFallback
|
import org.jetbrains.kotlin.cli.common.environment.setIdeaIoUseFallback
|
||||||
import org.jetbrains.kotlin.cli.common.messages.*
|
import org.jetbrains.kotlin.cli.common.messages.*
|
||||||
import org.jetbrains.kotlin.cli.common.messages.CompilerMessageSeverity.ERROR
|
import org.jetbrains.kotlin.cli.common.messages.CompilerMessageSeverity.*
|
||||||
import org.jetbrains.kotlin.cli.common.messages.CompilerMessageSeverity.INFO
|
|
||||||
import org.jetbrains.kotlin.cli.common.messages.CompilerMessageSeverity.LOGGING
|
|
||||||
import org.jetbrains.kotlin.cli.jvm.plugins.PluginCliParser
|
import org.jetbrains.kotlin.cli.jvm.plugins.PluginCliParser
|
||||||
import org.jetbrains.kotlin.cli.plugins.processCompilerPluginsOptions
|
import org.jetbrains.kotlin.cli.plugins.processCompilerPluginsOptions
|
||||||
import org.jetbrains.kotlin.compiler.plugin.CommandLineProcessor
|
import org.jetbrains.kotlin.compiler.plugin.CommandLineProcessor
|
||||||
@@ -48,13 +46,15 @@ import java.io.PrintStream
|
|||||||
|
|
||||||
abstract class CLICompiler<A : CommonCompilerArguments> : CLITool<A>() {
|
abstract class CLICompiler<A : CommonCompilerArguments> : CLITool<A>() {
|
||||||
companion object {
|
companion object {
|
||||||
const val SCRIPT_PLUGIN_REGISTRAR_NAME = "org.jetbrains.kotlin.scripting.compiler.plugin.ScriptingCompilerConfigurationComponentRegistrar"
|
const val SCRIPT_PLUGIN_REGISTRAR_NAME =
|
||||||
|
"org.jetbrains.kotlin.scripting.compiler.plugin.ScriptingCompilerConfigurationComponentRegistrar"
|
||||||
const val SCRIPT_PLUGIN_COMMANDLINE_PROCESSOR_NAME = "org.jetbrains.kotlin.scripting.compiler.plugin.ScriptingCommandLineProcessor"
|
const val SCRIPT_PLUGIN_COMMANDLINE_PROCESSOR_NAME = "org.jetbrains.kotlin.scripting.compiler.plugin.ScriptingCommandLineProcessor"
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract val defaultPerformanceManager: CommonCompilerPerformanceManager
|
abstract val defaultPerformanceManager: CommonCompilerPerformanceManager
|
||||||
|
|
||||||
protected open fun createPerformanceManager(arguments: A, services: Services): CommonCompilerPerformanceManager = defaultPerformanceManager
|
protected open fun createPerformanceManager(arguments: A, services: Services): CommonCompilerPerformanceManager =
|
||||||
|
defaultPerformanceManager
|
||||||
|
|
||||||
// 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)
|
||||||
fun execAndOutputXml(errStream: PrintStream, services: Services, vararg args: String): ExitCode {
|
fun execAndOutputXml(errStream: PrintStream, services: Services, vararg args: String): ExitCode {
|
||||||
@@ -179,23 +179,37 @@ abstract class CLICompiler<A : CommonCompilerArguments> : CLITool<A>() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pluginConfigurations.isNotEmpty() && (pluginClasspaths.isNotEmpty() || pluginOptions.isNotEmpty())) {
|
if (pluginConfigurations.isNotEmpty()) {
|
||||||
val message = buildString {
|
var hasErrors = false
|
||||||
appendLine("Mixing legacy and modern plugin arguments is prohibited. Please use only one syntax")
|
messageCollector.report(WARNING, "Argument -Xcompiler-plugin is experimental")
|
||||||
appendLine("Legacy arguments:")
|
if (!arguments.useK2) {
|
||||||
if (pluginClasspaths.isNotEmpty()) {
|
hasErrors = true
|
||||||
appendLine(" -Xplugin=${pluginClasspaths.joinToString(",")}")
|
messageCollector.report(
|
||||||
}
|
ERROR,
|
||||||
pluginOptions.forEach {
|
"-Xcompiler-plugin argument is allowed only for for K2 compiler. Please use -Xplugin argument or enable -Xuse-k2"
|
||||||
appendLine(" -P $it")
|
)
|
||||||
}
|
}
|
||||||
appendLine("Modern arguments:")
|
if (pluginClasspaths.isNotEmpty() || pluginOptions.isNotEmpty()) {
|
||||||
pluginConfigurations.forEach {
|
hasErrors = true
|
||||||
appendLine(" -Xcompiler-plugin=$it")
|
val message = buildString {
|
||||||
}
|
appendLine("Mixing legacy and modern plugin arguments is prohibited. Please use only one syntax")
|
||||||
|
appendLine("Legacy arguments:")
|
||||||
|
if (pluginClasspaths.isNotEmpty()) {
|
||||||
|
appendLine(" -Xplugin=${pluginClasspaths.joinToString(",")}")
|
||||||
|
}
|
||||||
|
pluginOptions.forEach {
|
||||||
|
appendLine(" -P $it")
|
||||||
|
}
|
||||||
|
appendLine("Modern arguments:")
|
||||||
|
pluginConfigurations.forEach {
|
||||||
|
appendLine(" -Xcompiler-plugin=$it")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
messageCollector.report(ERROR, message)
|
||||||
|
}
|
||||||
|
if (hasErrors) {
|
||||||
|
return INTERNAL_ERROR
|
||||||
}
|
}
|
||||||
messageCollector.report(ERROR, message)
|
|
||||||
return INTERNAL_ERROR
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!arguments.disableDefaultScriptingPlugin) {
|
if (!arguments.disableDefaultScriptingPlugin) {
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
-d
|
-d
|
||||||
$TEMP_DIR$
|
$TEMP_DIR$
|
||||||
|
-Xuse-k2
|
||||||
-Xcompiler-plugin=dist/kotlinc/lib/allopen-compiler-plugin.jar=annotation=foo.AllOpen
|
-Xcompiler-plugin=dist/kotlinc/lib/allopen-compiler-plugin.jar=annotation=foo.AllOpen
|
||||||
$TESTDATA_DIR$/firAllOpenPlugin.kt
|
$TESTDATA_DIR$/firAllOpenPlugin.kt
|
||||||
|
|||||||
@@ -1 +1,5 @@
|
|||||||
|
warning: argument -Xcompiler-plugin is experimental
|
||||||
|
warning: ATTENTION!
|
||||||
|
This build uses experimental K2 compiler:
|
||||||
|
-Xuse-k2
|
||||||
OK
|
OK
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
-d
|
-d
|
||||||
$TEMP_DIR$
|
$TEMP_DIR$
|
||||||
-Xcompiler-plugin=dist/kotlinc/lib/noarg-compiler-plugin.jar=annotation=foo.NoArg
|
-Xcompiler-plugin=dist/kotlinc/lib/noarg-compiler-plugin.jar=annotation=foo.NoArg
|
||||||
|
-Xuse-k2
|
||||||
|
|
||||||
-Xplugin=dist/kotlinc/lib/allopen-compiler-plugin.jar
|
-Xplugin=dist/kotlinc/lib/allopen-compiler-plugin.jar
|
||||||
-P
|
-P
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
-d
|
-d
|
||||||
$TEMP_DIR$
|
$TEMP_DIR$
|
||||||
|
-Xuse-k2
|
||||||
-Xcompiler-plugin=dist/kotlinc/lib/allopen-compiler-plugin.jar=annotation=foo.AllOpen1,annotation=foo.AllOpen2
|
-Xcompiler-plugin=dist/kotlinc/lib/allopen-compiler-plugin.jar=annotation=foo.AllOpen1,annotation=foo.AllOpen2
|
||||||
$TESTDATA_DIR$/multipleOptionsForOnePlugin.kt
|
$TESTDATA_DIR$/multipleOptionsForOnePlugin.kt
|
||||||
|
|||||||
@@ -1 +1,5 @@
|
|||||||
|
warning: argument -Xcompiler-plugin is experimental
|
||||||
|
warning: ATTENTION!
|
||||||
|
This build uses experimental K2 compiler:
|
||||||
|
-Xuse-k2
|
||||||
OK
|
OK
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
-d
|
-d
|
||||||
$TEMP_DIR$
|
$TEMP_DIR$
|
||||||
|
-Xuse-k2
|
||||||
-Xcompiler-plugin=dist/kotlinc/lib/allopen-compiler-plugin.jar=annotation=foo.AllOpen
|
-Xcompiler-plugin=dist/kotlinc/lib/allopen-compiler-plugin.jar=annotation=foo.AllOpen
|
||||||
-Xcompiler-plugin=dist/kotlinc/lib/noarg-compiler-plugin.jar=annotation=foo.NoArg
|
-Xcompiler-plugin=dist/kotlinc/lib/noarg-compiler-plugin.jar=annotation=foo.NoArg
|
||||||
$TESTDATA_DIR$/multiplePlugins.kt
|
$TESTDATA_DIR$/multiplePlugins.kt
|
||||||
|
|||||||
+4
-1
@@ -1,4 +1,7 @@
|
|||||||
compiler/testData/cli/jvm/plugins/multiplePlugins.kt:11:17: error: noarg constructor generation is not possible for inner classes
|
warning: ATTENTION!
|
||||||
|
This build uses experimental K2 compiler:
|
||||||
|
-Xuse-k2
|
||||||
|
compiler/testData/cli/jvm/plugins/multiplePlugins.kt:11:17: error:
|
||||||
inner class Inner(val s: String)
|
inner class Inner(val s: String)
|
||||||
^
|
^
|
||||||
COMPILATION_ERROR
|
COMPILATION_ERROR
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
-d
|
-d
|
||||||
$TEMP_DIR$
|
$TEMP_DIR$
|
||||||
|
-Xuse-k2
|
||||||
-Xcompiler-plugin=dist/kotlinc/lib/allopen-compiler-plugin.jar,dist/kotlinc/lib/noarg-compiler-plugin.jar=annotation=foo.AllOpen
|
-Xcompiler-plugin=dist/kotlinc/lib/allopen-compiler-plugin.jar,dist/kotlinc/lib/noarg-compiler-plugin.jar=annotation=foo.AllOpen
|
||||||
$TESTDATA_DIR$/multiplePluginsInSameArg.kt
|
$TESTDATA_DIR$/multiplePluginsInSameArg.kt
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
-d
|
-d
|
||||||
$TEMP_DIR$
|
$TEMP_DIR$
|
||||||
|
-Xuse-k2
|
||||||
-Xcompiler-plugin=dist/kotlinc/lib/kotlin-reflect.jar
|
-Xcompiler-plugin=dist/kotlinc/lib/kotlin-reflect.jar
|
||||||
$TESTDATA_DIR$/noPluginInClasspath.kt
|
$TESTDATA_DIR$/noPluginInClasspath.kt
|
||||||
|
|||||||
@@ -1 +0,0 @@
|
|||||||
OK
|
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
error: -Xcompiler-plugin argument is allowed only for for K2 compiler. Please use -Xplugin argument or enable -Xuse-k2
|
||||||
|
COMPILATION_ERROR
|
||||||
@@ -109,9 +109,9 @@ public class CliTestGenerated extends AbstractCliTest {
|
|||||||
runTest("compiler/testData/cli/jvm/plugins/pluginSimple_legacy.args");
|
runTest("compiler/testData/cli/jvm/plugins/pluginSimple_legacy.args");
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("pluginSimple_modern.args")
|
@TestMetadata("pluginSimple_modern_noK2.args")
|
||||||
public void testPluginSimple_modern() throws Exception {
|
public void testPluginSimple_modern_noK2() throws Exception {
|
||||||
runTest("compiler/testData/cli/jvm/plugins/pluginSimple_modern.args");
|
runTest("compiler/testData/cli/jvm/plugins/pluginSimple_modern_noK2.args");
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("pluginWithK2Error_legacy.args")
|
@TestMetadata("pluginWithK2Error_legacy.args")
|
||||||
|
|||||||
Reference in New Issue
Block a user