Track plugin options with indices
This commit is contained in:
+20
-5
@@ -51,7 +51,7 @@ internal class CompilerPluginOptionsBuilder(
|
|||||||
) {
|
) {
|
||||||
private val pluginOptions = CompilerPluginOptions()
|
private val pluginOptions = CompilerPluginOptions()
|
||||||
private val artifacts = mutableListOf<String>()
|
private val artifacts = mutableListOf<String>()
|
||||||
private val gradleInputs = mutableMapOf<String, String>()
|
private val gradleInputs = mutableMapOf<String, MutableList<String>>()
|
||||||
private val gradleInputFiles = mutableSetOf<File>()
|
private val gradleInputFiles = mutableSetOf<File>()
|
||||||
|
|
||||||
operator fun plusAssign(pluginData: PluginData) {
|
operator fun plusAssign(pluginData: PluginData) {
|
||||||
@@ -72,9 +72,13 @@ internal class CompilerPluginOptionsBuilder(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun addToInputs(pluginId: String, option: PluginOption) = when(option) {
|
private fun addToInputs(pluginId: String, option: PluginOption) {
|
||||||
is FilesOption -> gradleInputFiles += option.files
|
when(option) {
|
||||||
is StringOption -> gradleInputs["${pluginId}.${option.key}"] = option.value
|
is FilesOption -> gradleInputFiles += option.files
|
||||||
|
is StringOption -> gradleInputs
|
||||||
|
.getOrPut("${pluginId}.${option.key}") { mutableListOf() }
|
||||||
|
.add(option.value)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun build(): KotlinCompilerPluginData {
|
fun build(): KotlinCompilerPluginData {
|
||||||
@@ -89,11 +93,22 @@ internal class CompilerPluginOptionsBuilder(
|
|||||||
return KotlinCompilerPluginData(
|
return KotlinCompilerPluginData(
|
||||||
classpath = pluginClasspathConfiguration,
|
classpath = pluginClasspathConfiguration,
|
||||||
options = pluginOptions,
|
options = pluginOptions,
|
||||||
inputs = gradleInputs,
|
inputs = gradleInputs.flattenWithIndex(),
|
||||||
inputFiles = gradleInputFiles
|
inputFiles = gradleInputFiles
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun Map<String,List<String>>.flattenWithIndex(): Map<String, String> {
|
||||||
|
val result = mutableMapOf<String, String>()
|
||||||
|
|
||||||
|
for ((key, values) in this) {
|
||||||
|
for ((index, value) in values.withIndex()) {
|
||||||
|
result["${key}.$index"] = value
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
|
||||||
private fun PluginOption.toSubpluginOption() = when (this) {
|
private fun PluginOption.toSubpluginOption() = when (this) {
|
||||||
is FilesOption -> FilesSubpluginOption(key, files)
|
is FilesOption -> FilesSubpluginOption(key, files)
|
||||||
|
|||||||
Reference in New Issue
Block a user