mirror of
https://github.com/InsanusMokrassar/MicroUtils.git
synced 2024-11-22 16:23:50 +00:00
add support of native in startup
This commit is contained in:
parent
d01ad10d7d
commit
ca73ff8e19
@ -2,6 +2,9 @@
|
||||
|
||||
## 0.17.7
|
||||
|
||||
* `Startup`:
|
||||
* Add support of `linuxX64` and `mingwX64` platforms
|
||||
|
||||
## 0.17.6
|
||||
|
||||
* `Versions`:
|
||||
|
@ -23,7 +23,7 @@ allprojects {
|
||||
mppProjectWithSerializationPresetPath = "${rootProject.projectDir.absolutePath}/mppProjectWithSerialization.gradle"
|
||||
mppProjectWithSerializationAndComposePresetPath = "${rootProject.projectDir.absolutePath}/mppProjectWithSerializationAndCompose.gradle"
|
||||
mppJavaProjectPresetPath = "${rootProject.projectDir.absolutePath}/mppJavaProject.gradle"
|
||||
mppJsAndJavaProjectPresetPath = "${rootProject.projectDir.absolutePath}/mppJsAndJavaProject.gradle"
|
||||
mppJvmJsLinuxMingwProjectPresetPath = "${rootProject.projectDir.absolutePath}/mppJvmJsLinuxMingwProject.gradle"
|
||||
mppAndroidProjectPresetPath = "${rootProject.projectDir.absolutePath}/mppAndroidProject.gradle"
|
||||
|
||||
defaultAndroidSettingsPresetPath = "${rootProject.projectDir.absolutePath}/defaultAndroidSettings.gradle"
|
||||
|
@ -15,6 +15,8 @@ kotlin {
|
||||
browser()
|
||||
nodejs()
|
||||
}
|
||||
linuxX64()
|
||||
mingwX64()
|
||||
|
||||
sourceSets {
|
||||
commonMain {
|
@ -4,7 +4,7 @@ plugins {
|
||||
id "application"
|
||||
}
|
||||
|
||||
apply from: "$mppJsAndJavaProjectPresetPath"
|
||||
apply from: "$mppJvmJsLinuxMingwProjectPresetPath"
|
||||
|
||||
kotlin {
|
||||
sourceSets {
|
||||
|
@ -3,7 +3,7 @@ plugins {
|
||||
id "org.jetbrains.kotlin.plugin.serialization"
|
||||
}
|
||||
|
||||
apply from: "$mppJsAndJavaProjectPresetPath"
|
||||
apply from: "$mppJvmJsLinuxMingwProjectPresetPath"
|
||||
|
||||
kotlin {
|
||||
sourceSets {
|
||||
@ -21,5 +21,15 @@ kotlin {
|
||||
api libs.uuid
|
||||
}
|
||||
}
|
||||
linuxX64Main {
|
||||
dependencies {
|
||||
api libs.uuid
|
||||
}
|
||||
}
|
||||
mingwX64Main {
|
||||
dependencies {
|
||||
api libs.uuid
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,36 @@
|
||||
package dev.inmo.micro_utils.startup.plugin
|
||||
|
||||
import com.benasher44.uuid.uuid4
|
||||
import kotlinx.serialization.KSerializer
|
||||
import kotlinx.serialization.builtins.serializer
|
||||
import kotlinx.serialization.descriptors.SerialDescriptor
|
||||
import kotlinx.serialization.encoding.Decoder
|
||||
import kotlinx.serialization.encoding.Encoder
|
||||
import kotlin.reflect.KClass
|
||||
|
||||
actual object StartPluginSerializer : KSerializer<StartPlugin> {
|
||||
private val registeredPlugins = mutableMapOf<String, StartPlugin>()
|
||||
private val registeredPluginsByPlugin = mutableMapOf<StartPlugin, String>()
|
||||
override val descriptor: SerialDescriptor = String.serializer().descriptor
|
||||
|
||||
override fun deserialize(decoder: Decoder): StartPlugin {
|
||||
val name = decoder.decodeString()
|
||||
return registeredPlugins[name] ?: error("Unable to find startup plugin for $name")
|
||||
}
|
||||
|
||||
override fun serialize(encoder: Encoder, value: StartPlugin) {
|
||||
val name = registeredPluginsByPlugin[value] ?: uuid4().toString().also {
|
||||
registeredPlugins[it] = value
|
||||
registeredPluginsByPlugin[value] = it
|
||||
}
|
||||
encoder.encodeString(name)
|
||||
}
|
||||
|
||||
/**
|
||||
* Register plugin inside of this [KSerializer]. Since plugin has been registered, you may use its [name] in any
|
||||
* serialized [dev.inmo.micro_utils.startup.launcher.Config] to retrieve [plugin] you passed here
|
||||
*/
|
||||
fun registerPlugin(name: String, plugin: StartPlugin) {
|
||||
registeredPlugins[name] = plugin
|
||||
}
|
||||
}
|
@ -0,0 +1,36 @@
|
||||
package dev.inmo.micro_utils.startup.plugin
|
||||
|
||||
import com.benasher44.uuid.uuid4
|
||||
import kotlinx.serialization.KSerializer
|
||||
import kotlinx.serialization.builtins.serializer
|
||||
import kotlinx.serialization.descriptors.SerialDescriptor
|
||||
import kotlinx.serialization.encoding.Decoder
|
||||
import kotlinx.serialization.encoding.Encoder
|
||||
import kotlin.reflect.KClass
|
||||
|
||||
actual object StartPluginSerializer : KSerializer<StartPlugin> {
|
||||
private val registeredPlugins = mutableMapOf<String, StartPlugin>()
|
||||
private val registeredPluginsByPlugin = mutableMapOf<StartPlugin, String>()
|
||||
override val descriptor: SerialDescriptor = String.serializer().descriptor
|
||||
|
||||
override fun deserialize(decoder: Decoder): StartPlugin {
|
||||
val name = decoder.decodeString()
|
||||
return registeredPlugins[name] ?: error("Unable to find startup plugin for $name")
|
||||
}
|
||||
|
||||
override fun serialize(encoder: Encoder, value: StartPlugin) {
|
||||
val name = registeredPluginsByPlugin[value] ?: uuid4().toString().also {
|
||||
registeredPlugins[it] = value
|
||||
registeredPluginsByPlugin[value] = it
|
||||
}
|
||||
encoder.encodeString(name)
|
||||
}
|
||||
|
||||
/**
|
||||
* Register plugin inside of this [KSerializer]. Since plugin has been registered, you may use its [name] in any
|
||||
* serialized [dev.inmo.micro_utils.startup.launcher.Config] to retrieve [plugin] you passed here
|
||||
*/
|
||||
fun registerPlugin(name: String, plugin: StartPlugin) {
|
||||
registeredPlugins[name] = plugin
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user