Allow optional 'name' property for plugin.yml

This commit is contained in:
Him188 2020-12-01 10:25:28 +08:00
parent f802415c7a
commit 6e7de8747c

View File

@ -52,7 +52,7 @@ public interface JvmPluginDescription : PluginDescription {
val bytes = stream.use { it.readBytes() } val bytes = stream.use { it.readBytes() }
return Yaml.default.decodeFromString(SimpleJvmPluginDescription.serializer(), String(bytes)) return Yaml.default.decodeFromString(SimpleJvmPluginDescription.SerialData.serializer(), String(bytes)).toJvmPluginDescription()
} }
} }
} }
@ -218,7 +218,7 @@ public class JvmPluginDescriptionBuilder(
* *
* @see JvmPluginDescription * @see JvmPluginDescription
*/ */
@Serializable // Keep this file in public API files. Might turn to `public` in the future. // @Serializable // Keep this file in public API files. Might turn to `public` in the future.
internal data class SimpleJvmPluginDescription internal data class SimpleJvmPluginDescription
@JvmOverloads constructor( @JvmOverloads constructor(
override val id: String, override val id: String,
@ -243,4 +243,23 @@ internal data class SimpleJvmPluginDescription
init { init {
PluginDescription.checkPluginDescription(this) PluginDescription.checkPluginDescription(this)
} }
@Serializable // Keep this file in public API files. Might turn to `public` in the future.
internal data class SerialData
@JvmOverloads constructor(
val id: String,
val name: String? = null, // workaround to ktx-serialization bug
val version: SemVersion,
val author: String = "",
val info: String = "",
val dependencies: Set<PluginDependency> = setOf(),
) {
fun toJvmPluginDescription(): JvmPluginDescription {
return SimpleJvmPluginDescription(
id,
name ?: id,
version, author, info, dependencies
)
}
}
} }