Localize plugin string format usages
This commit is contained in:
@@ -37,12 +37,12 @@ import org.jetbrains.kotlin.compiler.plugin.ComponentRegistrar
|
||||
import java.util.ServiceLoader
|
||||
import java.io.IOException
|
||||
import java.util.Enumeration
|
||||
import org.jetbrains.kotlin.compiler.plugin.parsePluginOption
|
||||
import org.jetbrains.kotlin.compiler.plugin.PluginOptionValue
|
||||
|
||||
|
||||
public object PluginCliParser {
|
||||
|
||||
public val PLUGIN_ARGUMENT_PREFIX: String = "plugin:"
|
||||
|
||||
[platformStatic]
|
||||
fun loadPlugins(arguments: CommonCompilerArguments, configuration: CompilerConfiguration) {
|
||||
val classLoader = PluginURLClassLoader(
|
||||
@@ -100,24 +100,6 @@ public object PluginCliParser {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private class PluginOptionValue(
|
||||
val pluginId: String,
|
||||
val optionName: String,
|
||||
val value: String
|
||||
) {
|
||||
override fun toString() = "$pluginId:$optionName=$value"
|
||||
}
|
||||
|
||||
private fun parsePluginOption(argumentValue: String): PluginOptionValue? {
|
||||
val pattern = Pattern.compile("""^plugin:([^:]*):([^=]*)=(.*)$""")
|
||||
val matcher = pattern.matcher(argumentValue)
|
||||
if (matcher.matches()) {
|
||||
return PluginOptionValue(matcher.group(1)!!, matcher.group(2)!!, matcher.group(3)!!)
|
||||
}
|
||||
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
private class PluginURLClassLoader(urls: Array<URL>, parent: ClassLoader) : ClassLoader(Thread.currentThread().getContextClassLoader()) {
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
package org.jetbrains.kotlin.compiler.plugin
|
||||
|
||||
import org.jetbrains.jet.config.CompilerConfiguration
|
||||
import java.util.regex.Pattern
|
||||
|
||||
public class CliOption(
|
||||
public val name: String,
|
||||
@@ -36,6 +37,24 @@ public trait CommandLineProcessor {
|
||||
public fun processOption(option: CliOption, value: String, configuration: CompilerConfiguration)
|
||||
}
|
||||
|
||||
public data class PluginOptionValue(
|
||||
val pluginId: String,
|
||||
val optionName: String,
|
||||
val value: String
|
||||
) {
|
||||
override fun toString() = "$pluginId:$optionName=$value"
|
||||
}
|
||||
|
||||
public fun parsePluginOption(argumentValue: String): PluginOptionValue? {
|
||||
val pattern = Pattern.compile("""^plugin:([^:]*):([^=]*)=(.*)$""")
|
||||
val matcher = pattern.matcher(argumentValue)
|
||||
if (matcher.matches()) {
|
||||
return PluginOptionValue(matcher.group(1), matcher.group(2), matcher.group(3))
|
||||
}
|
||||
|
||||
return null
|
||||
}
|
||||
|
||||
public fun getPluginOptionString(pluginId: String, key: String, value: String): String {
|
||||
return "plugin:$pluginId:$key=$value"
|
||||
}
|
||||
@@ -25,15 +25,17 @@ import org.jetbrains.jps.android.AndroidJpsUtil
|
||||
import org.jetbrains.kotlin.compiler.plugin.CliOption
|
||||
import org.jetbrains.kotlin.android.AndroidCommandLineProcessor
|
||||
import org.jetbrains.jet.utils.PathUtil
|
||||
import org.jetbrains.kotlin.compiler.plugin.getPluginOptionString
|
||||
|
||||
public class KotlinAndroidJpsPlugin : KotlinJpsCompilerArgumentsProvider {
|
||||
private val jarFileName = "android-compiler-plugin.jar"
|
||||
|
||||
override fun getExtraArguments(moduleBuildTarget: ModuleBuildTarget, context: CompileContext): List<String> {
|
||||
val module = moduleBuildTarget.getModule()
|
||||
val pluginId = AndroidCommandLineProcessor.ANDROID_COMPILER_PLUGIN_ID
|
||||
return listOf(
|
||||
makePluginOption(AndroidCommandLineProcessor.RESOURCE_PATH_OPTION, getAndroidResPath(module)),
|
||||
makePluginOption(AndroidCommandLineProcessor.MANIFEST_FILE_OPTION, getAndroidManifest(module))
|
||||
getPluginOptionString(pluginId, AndroidCommandLineProcessor.RESOURCE_PATH_OPTION.name, getAndroidResPath(module)),
|
||||
getPluginOptionString(pluginId, AndroidCommandLineProcessor.MANIFEST_FILE_OPTION.name, getAndroidManifest(module))
|
||||
)
|
||||
}
|
||||
|
||||
@@ -51,10 +53,6 @@ public class KotlinAndroidJpsPlugin : KotlinJpsCompilerArgumentsProvider {
|
||||
)
|
||||
}
|
||||
|
||||
private fun makePluginOption(option: CliOption, value: String): String {
|
||||
return "plugin:${AndroidCommandLineProcessor.ANDROID_COMPILER_PLUGIN_ID}:${option.name}=$value"
|
||||
}
|
||||
|
||||
private fun getAndroidResPath(module: JpsModule): String {
|
||||
val extension = AndroidJpsUtil.getExtension(module)
|
||||
if (extension == null) return ""
|
||||
|
||||
Reference in New Issue
Block a user