[CLI] Introduce new compiler arguments for registering compiler plugins

With new syntax each plugin should be registered in separate argument with syntax
`-Xcompiler-plugin=classpath1,classpath2[=argument1=value1,argument2=value2]`
This commit is contained in:
Dmitriy Novozhilov
2022-06-29 15:02:58 +03:00
committed by teamcity
parent 8919703448
commit 928416c9c5
39 changed files with 361 additions and 67 deletions
@@ -44,6 +44,8 @@ class PluginCliOptionProcessingException(
cause: Throwable? = null
) : CliOptionProcessingException(message, cause)
class PluginProcessingException(message: String, cause: Throwable? = null) : RuntimeException(message, cause)
fun cliPluginUsageString(pluginId: String, options: Collection<AbstractCliOption>): String {
val LEFT_INDENT = 2
val MAX_OPTION_WIDTH = 26
@@ -73,7 +75,7 @@ data class CliOptionValue(
override fun toString() = "$pluginId:$optionName=$value"
}
fun parsePluginOption(argumentValue: String): CliOptionValue? {
fun parseLegacyPluginOption(argumentValue: String): CliOptionValue? {
val pattern = Pattern.compile("""^plugin:([^:]*):([^=]*)=(.*)$""")
val matcher = pattern.matcher(argumentValue)
if (matcher.matches()) {
@@ -83,6 +85,16 @@ fun parsePluginOption(argumentValue: String): CliOptionValue? {
return null
}
fun parseModernPluginOption(argumentValue: String): CliOptionValue? {
val pattern = Pattern.compile("""^([^=]*)=(.*)$""")
val matcher = pattern.matcher(argumentValue)
if (matcher.matches()) {
return CliOptionValue("<NO_ID>", matcher.group(1), matcher.group(2))
}
return null
}
fun getPluginOptionString(pluginId: String, key: String, value: String): String {
return "plugin:$pluginId:$key=$value"
}