mirror of
https://github.com/InsanusMokrassar/MicroUtils.git
synced 2024-12-23 09:07:14 +00:00
commit
dbc921d56d
@ -1,5 +1,10 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
## 0.18.2
|
||||||
|
|
||||||
|
* `Startup`:
|
||||||
|
* Now internal `Json` is fully customizable
|
||||||
|
|
||||||
## 0.18.1
|
## 0.18.1
|
||||||
|
|
||||||
* `Common`:
|
* `Common`:
|
||||||
|
@ -14,5 +14,5 @@ crypto_js_version=4.1.1
|
|||||||
# Project data
|
# Project data
|
||||||
|
|
||||||
group=dev.inmo
|
group=dev.inmo
|
||||||
version=0.18.1
|
version=0.18.2
|
||||||
android_code_version=192
|
android_code_version=193
|
||||||
|
@ -2,6 +2,7 @@ plugins {
|
|||||||
id "org.jetbrains.kotlin.multiplatform"
|
id "org.jetbrains.kotlin.multiplatform"
|
||||||
id "org.jetbrains.kotlin.plugin.serialization"
|
id "org.jetbrains.kotlin.plugin.serialization"
|
||||||
id "application"
|
id "application"
|
||||||
|
id "com.google.devtools.ksp"
|
||||||
}
|
}
|
||||||
|
|
||||||
apply from: "$mppJvmJsLinuxMingwProjectPresetPath"
|
apply from: "$mppJvmJsLinuxMingwProjectPresetPath"
|
||||||
@ -11,6 +12,7 @@ kotlin {
|
|||||||
commonMain {
|
commonMain {
|
||||||
dependencies {
|
dependencies {
|
||||||
api internalProject("micro_utils.startup.plugin")
|
api internalProject("micro_utils.startup.plugin")
|
||||||
|
api internalProject("micro_utils.koin")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
commonTest {
|
commonTest {
|
||||||
@ -29,3 +31,10 @@ java {
|
|||||||
sourceCompatibility = JavaVersion.VERSION_1_8
|
sourceCompatibility = JavaVersion.VERSION_1_8
|
||||||
targetCompatibility = JavaVersion.VERSION_1_8
|
targetCompatibility = JavaVersion.VERSION_1_8
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
add("kspCommonMainMetadata", project(":micro_utils.koin.generator"))
|
||||||
|
}
|
||||||
|
|
||||||
|
ksp {
|
||||||
|
}
|
||||||
|
@ -0,0 +1,38 @@
|
|||||||
|
// THIS CODE HAVE BEEN GENERATED AUTOMATICALLY
|
||||||
|
// TO REGENERATE IT JUST DELETE FILE
|
||||||
|
// ORIGINAL FILE: StartLauncherPlugin.kt
|
||||||
|
package dev.inmo.micro_utils.startup.launcher
|
||||||
|
|
||||||
|
import kotlin.Boolean
|
||||||
|
import kotlinx.serialization.json.Json
|
||||||
|
import org.koin.core.Koin
|
||||||
|
import org.koin.core.definition.Definition
|
||||||
|
import org.koin.core.definition.KoinDefinition
|
||||||
|
import org.koin.core.module.Module
|
||||||
|
import org.koin.core.qualifier.named
|
||||||
|
import org.koin.core.scope.Scope
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Definition by key "baseJsonProvider"
|
||||||
|
*/
|
||||||
|
public val Scope.baseJsonProvider: Json?
|
||||||
|
get() = getOrNull(named("baseJsonProvider"))
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Definition by key "baseJsonProvider"
|
||||||
|
*/
|
||||||
|
public val Koin.baseJsonProvider: Json?
|
||||||
|
get() = getOrNull(named("baseJsonProvider"))
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Will register [definition] with [org.koin.core.module.Module.single] and key "baseJsonProvider"
|
||||||
|
*/
|
||||||
|
public fun Module.baseJsonProviderSingle(createdAtStart: Boolean = false, definition: Definition<Json>):
|
||||||
|
KoinDefinition<Json> = single(named("baseJsonProvider"), createdAtStart = createdAtStart, definition
|
||||||
|
= definition)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Will register [definition] with [org.koin.core.module.Module.factory] and key "baseJsonProvider"
|
||||||
|
*/
|
||||||
|
public fun Module.baseJsonProviderFactory(definition: Definition<Json>): KoinDefinition<Json> =
|
||||||
|
factory(named("baseJsonProvider"), definition = definition)
|
@ -1,9 +1,11 @@
|
|||||||
|
@file:GenerateKoinDefinition("baseJsonProvider", Json::class)
|
||||||
package dev.inmo.micro_utils.startup.launcher
|
package dev.inmo.micro_utils.startup.launcher
|
||||||
|
|
||||||
import dev.inmo.kslog.common.i
|
import dev.inmo.kslog.common.i
|
||||||
import dev.inmo.kslog.common.taggedLogger
|
import dev.inmo.kslog.common.taggedLogger
|
||||||
import dev.inmo.kslog.common.w
|
import dev.inmo.kslog.common.w
|
||||||
import dev.inmo.micro_utils.coroutines.runCatchingSafely
|
import dev.inmo.micro_utils.coroutines.runCatchingSafely
|
||||||
|
import dev.inmo.micro_utils.koin.annotations.GenerateKoinDefinition
|
||||||
import dev.inmo.micro_utils.startup.launcher.StartLauncherPlugin.setupDI
|
import dev.inmo.micro_utils.startup.launcher.StartLauncherPlugin.setupDI
|
||||||
import dev.inmo.micro_utils.startup.launcher.StartLauncherPlugin.startPlugin
|
import dev.inmo.micro_utils.startup.launcher.StartLauncherPlugin.startPlugin
|
||||||
import dev.inmo.micro_utils.startup.plugin.StartPlugin
|
import dev.inmo.micro_utils.startup.plugin.StartPlugin
|
||||||
@ -13,9 +15,10 @@ import kotlinx.coroutines.joinAll
|
|||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import kotlinx.serialization.SerialFormat
|
import kotlinx.serialization.SerialFormat
|
||||||
import kotlinx.serialization.StringFormat
|
import kotlinx.serialization.StringFormat
|
||||||
|
import kotlinx.serialization.json.Json
|
||||||
import kotlinx.serialization.json.JsonObject
|
import kotlinx.serialization.json.JsonObject
|
||||||
import kotlinx.serialization.json.decodeFromJsonElement
|
|
||||||
import kotlinx.serialization.json.jsonObject
|
import kotlinx.serialization.json.jsonObject
|
||||||
|
import kotlinx.serialization.modules.SerializersModule
|
||||||
import org.koin.core.Koin
|
import org.koin.core.Koin
|
||||||
import org.koin.core.KoinApplication
|
import org.koin.core.KoinApplication
|
||||||
import org.koin.core.context.startKoin
|
import org.koin.core.context.startKoin
|
||||||
@ -35,7 +38,20 @@ object StartLauncherPlugin : StartPlugin {
|
|||||||
single { rawJsonObject }
|
single { rawJsonObject }
|
||||||
single { config }
|
single { config }
|
||||||
single { CoroutineScope(Dispatchers.Default) }
|
single { CoroutineScope(Dispatchers.Default) }
|
||||||
single { defaultJson } binds arrayOf(StringFormat::class, SerialFormat::class)
|
single {
|
||||||
|
val serializersModules = getAll<SerializersModule>().distinct()
|
||||||
|
val baseJson = baseJsonProvider ?: defaultJson
|
||||||
|
if (serializersModules.isEmpty()) {
|
||||||
|
baseJson
|
||||||
|
} else {
|
||||||
|
Json(baseJson) {
|
||||||
|
serializersModule = SerializersModule {
|
||||||
|
include(baseJson.serializersModule)
|
||||||
|
serializersModules.forEach { include(it) }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} binds arrayOf(StringFormat::class, SerialFormat::class)
|
||||||
|
|
||||||
includes(
|
includes(
|
||||||
config.plugins.mapNotNull {
|
config.plugins.mapNotNull {
|
||||||
|
Loading…
Reference in New Issue
Block a user