mirror of
https://github.com/InsanusMokrassar/MicroUtils.git
synced 2025-09-17 22:39:25 +00:00
Compare commits
9 Commits
Author | SHA1 | Date | |
---|---|---|---|
8b43d785cc | |||
b62d3a0b7d | |||
fad73c7213 | |||
2403c7c2b0 | |||
fa090bf920 | |||
a83ee86340 | |||
204955bcce | |||
ee56e9543a | |||
96fdff6ffd |
11
CHANGELOG.md
11
CHANGELOG.md
@@ -1,5 +1,16 @@
|
||||
# Changelog
|
||||
|
||||
## 0.16.4
|
||||
|
||||
* `Coroutines`:
|
||||
* Create `launchInCurrentThread`
|
||||
|
||||
## 0.16.3
|
||||
|
||||
* `Startup`:
|
||||
* `Launcher`:
|
||||
* All starting API have been moved into `StartLauncherPlugin` and do not require serialize/deserialize cycle for now
|
||||
|
||||
## 0.16.2
|
||||
|
||||
* `Versions`:
|
||||
|
@@ -22,6 +22,7 @@ kotlin {
|
||||
dependencies {
|
||||
api libs.kt.coroutines.android
|
||||
}
|
||||
dependsOn(jvmMain)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,9 @@
|
||||
package dev.inmo.micro_utils.coroutines
|
||||
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
|
||||
fun <T> launchInCurrentThread(block: suspend CoroutineScope.() -> T): T {
|
||||
val scope = CoroutineScope(Dispatchers.Unconfined)
|
||||
return scope.launchSynchronously(block)
|
||||
}
|
@@ -6,7 +6,7 @@ fun <T> CoroutineScope.launchSynchronously(block: suspend CoroutineScope.() -> T
|
||||
var result: Result<T>? = null
|
||||
val objectToSynchronize = Object()
|
||||
synchronized(objectToSynchronize) {
|
||||
launch {
|
||||
launch(start = CoroutineStart.UNDISPATCHED) {
|
||||
result = safelyWithResult(block)
|
||||
}.invokeOnCompletion {
|
||||
synchronized(objectToSynchronize) {
|
||||
|
@@ -0,0 +1,47 @@
|
||||
package dev.inmo.micro_utils.coroutines
|
||||
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.delay
|
||||
import kotlinx.coroutines.withContext
|
||||
import kotlin.test.Test
|
||||
import kotlin.test.assertEquals
|
||||
|
||||
class LaunchInCurrentThreadTests {
|
||||
@Test
|
||||
fun simpleTestThatLaunchInCurrentThreadWorks() {
|
||||
val expectedResult = 10
|
||||
val result = launchInCurrentThread {
|
||||
expectedResult
|
||||
}
|
||||
assertEquals(expectedResult, result)
|
||||
}
|
||||
@Test
|
||||
fun simpleTestThatSeveralLaunchInCurrentThreadWorks() {
|
||||
val testData = 0 until 100
|
||||
|
||||
testData.forEach {
|
||||
val result = launchInCurrentThread {
|
||||
it
|
||||
}
|
||||
assertEquals(it, result)
|
||||
}
|
||||
}
|
||||
@Test
|
||||
fun simpleTestThatLaunchInCurrentThreadWillCorrectlyHandleSuspensionsWorks() {
|
||||
val testData = 0 until 100
|
||||
|
||||
suspend fun test(data: Any): Any {
|
||||
return withContext(Dispatchers.Default) {
|
||||
delay(1)
|
||||
data
|
||||
}
|
||||
}
|
||||
|
||||
testData.forEach {
|
||||
val result = launchInCurrentThread {
|
||||
test(it)
|
||||
}
|
||||
assertEquals(it, result)
|
||||
}
|
||||
}
|
||||
}
|
@@ -14,5 +14,5 @@ crypto_js_version=4.1.1
|
||||
# Project data
|
||||
|
||||
group=dev.inmo
|
||||
version=0.16.2
|
||||
android_code_version=170
|
||||
version=0.16.4
|
||||
android_code_version=172
|
||||
|
@@ -1,10 +1,8 @@
|
||||
package dev.inmo.micro_utils.startup.launcher
|
||||
|
||||
import dev.inmo.kslog.common.i
|
||||
import dev.inmo.micro_utils.startup.launcher.StartLauncherPlugin.setupDI
|
||||
import kotlinx.serialization.json.JsonObject
|
||||
import org.koin.core.KoinApplication
|
||||
import org.koin.core.context.startKoin
|
||||
import org.koin.dsl.module
|
||||
|
||||
/**
|
||||
* Will create [KoinApplication], init, load modules using [StartLauncherPlugin] and start plugins using the same base
|
||||
@@ -13,19 +11,7 @@ import org.koin.dsl.module
|
||||
* @param rawConfig It is expected that this [JsonObject] will contain serialized [Config] ([StartLauncherPlugin] will
|
||||
* deserialize it in its [StartLauncherPlugin.setupDI]
|
||||
*/
|
||||
@Deprecated("Fully replaced with StartLauncherPlugin#start", ReplaceWith("StartLauncherPlugin.start(rawConfig)", "dev.inmo.micro_utils.startup.launcher.StartLauncherPlugin"))
|
||||
suspend fun start(rawConfig: JsonObject) {
|
||||
with(StartLauncherPlugin) {
|
||||
logger.i("Start initialization")
|
||||
val koinApp = KoinApplication.init()
|
||||
koinApp.modules(
|
||||
module {
|
||||
setupDI(rawConfig)
|
||||
}
|
||||
)
|
||||
logger.i("Modules loaded")
|
||||
startKoin(koinApp)
|
||||
logger.i("Koin started")
|
||||
startPlugin(koinApp.koin)
|
||||
logger.i("App has been setup")
|
||||
}
|
||||
StartLauncherPlugin.start(rawConfig)
|
||||
}
|
||||
|
@@ -4,6 +4,8 @@ import dev.inmo.kslog.common.i
|
||||
import dev.inmo.kslog.common.taggedLogger
|
||||
import dev.inmo.kslog.common.w
|
||||
import dev.inmo.micro_utils.coroutines.runCatchingSafely
|
||||
import dev.inmo.micro_utils.startup.launcher.StartLauncherPlugin.setupDI
|
||||
import dev.inmo.micro_utils.startup.launcher.StartLauncherPlugin.startPlugin
|
||||
import dev.inmo.micro_utils.startup.plugin.StartPlugin
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
@@ -12,7 +14,10 @@ import kotlinx.coroutines.launch
|
||||
import kotlinx.serialization.SerialFormat
|
||||
import kotlinx.serialization.StringFormat
|
||||
import kotlinx.serialization.json.JsonObject
|
||||
import kotlinx.serialization.json.jsonObject
|
||||
import org.koin.core.Koin
|
||||
import org.koin.core.KoinApplication
|
||||
import org.koin.core.context.startKoin
|
||||
import org.koin.core.module.Module
|
||||
import org.koin.dsl.binds
|
||||
import org.koin.dsl.module
|
||||
@@ -23,26 +28,20 @@ import org.koin.dsl.module
|
||||
object StartLauncherPlugin : StartPlugin {
|
||||
internal val logger = taggedLogger(this)
|
||||
|
||||
/**
|
||||
* Will deserialize [Config] from [config], register it in receiver [Module] (as well as [CoroutineScope] and
|
||||
* [kotlinx.serialization.json.Json])
|
||||
*
|
||||
* Besides, in this method will be called [StartPlugin.setupDI] on each plugin from [Config.plugins]. In case when
|
||||
* some plugin will not be loaded correctly it will be reported throw the [logger]
|
||||
*/
|
||||
override fun Module.setupDI(config: JsonObject) {
|
||||
val pluginsConfig = defaultJson.decodeFromJsonElement(Config.serializer(), config)
|
||||
fun Module.setupDI(config: Config, rawJsonObject: JsonObject? = null) {
|
||||
val rawJsonObject = rawJsonObject ?: defaultJson.encodeToJsonElement(Config.serializer(), config).jsonObject
|
||||
|
||||
single { pluginsConfig }
|
||||
single { rawJsonObject }
|
||||
single { config }
|
||||
single { CoroutineScope(Dispatchers.Default) }
|
||||
single { defaultJson } binds arrayOf(StringFormat::class, SerialFormat::class)
|
||||
|
||||
includes(
|
||||
pluginsConfig.plugins.mapNotNull {
|
||||
config.plugins.mapNotNull {
|
||||
runCatching {
|
||||
module {
|
||||
with(it) {
|
||||
setupDI(config)
|
||||
setupDI(rawJsonObject)
|
||||
}
|
||||
}
|
||||
}.onFailure { e ->
|
||||
@@ -52,11 +51,28 @@ object StartLauncherPlugin : StartPlugin {
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Will deserialize [Config] from [config], register it in receiver [Module] (as well as [CoroutineScope] and
|
||||
* [kotlinx.serialization.json.Json])
|
||||
*
|
||||
* Besides, in this method will be called [StartPlugin.setupDI] on each plugin from [Config.plugins]. In case when
|
||||
* some plugin will not be loaded correctly it will be reported throw the [logger]
|
||||
*/
|
||||
override fun Module.setupDI(config: JsonObject) {
|
||||
logger.i("Koin for current module has started setup")
|
||||
setupDI(
|
||||
defaultJson.decodeFromJsonElement(Config.serializer(), config),
|
||||
config
|
||||
)
|
||||
logger.i("Koin for current module has been setup")
|
||||
}
|
||||
|
||||
/**
|
||||
* Takes [CoroutineScope] and [Config] from the [koin], and call starting of each plugin from [Config.plugins]
|
||||
* ASYNCHRONOUSLY. Just like in [setupDI], in case of fail in some plugin it will be reported using [logger]
|
||||
*/
|
||||
override suspend fun startPlugin(koin: Koin) {
|
||||
logger.i("Start starting of subplugins")
|
||||
val scope = koin.get<CoroutineScope>()
|
||||
koin.get<Config>().plugins.map { plugin ->
|
||||
scope.launch {
|
||||
@@ -66,11 +82,60 @@ object StartLauncherPlugin : StartPlugin {
|
||||
startPlugin(koin)
|
||||
}
|
||||
}.onFailure { e ->
|
||||
logger.w("Unable to load bot part of $plugin", e)
|
||||
logger.w("Unable to start plugin $plugin", e)
|
||||
}.onSuccess {
|
||||
logger.i("Complete loading of $plugin")
|
||||
}
|
||||
}
|
||||
}.joinAll()
|
||||
logger.i("Complete subplugins start")
|
||||
}
|
||||
|
||||
/**
|
||||
* Will create [KoinApplication], init, load modules using [StartLauncherPlugin] and start plugins using the same base
|
||||
* plugin
|
||||
*
|
||||
* @param rawConfig It is expected that this [JsonObject] will contain serialized [Config] ([StartLauncherPlugin] will
|
||||
* deserialize it in its [StartLauncherPlugin.setupDI]
|
||||
*/
|
||||
suspend fun start(rawConfig: JsonObject) {
|
||||
|
||||
logger.i("Start initialization")
|
||||
val koinApp = KoinApplication.init()
|
||||
koinApp.modules(
|
||||
module {
|
||||
setupDI(rawConfig)
|
||||
}
|
||||
)
|
||||
logger.i("Modules loaded")
|
||||
startKoin(koinApp)
|
||||
logger.i("Koin started")
|
||||
startPlugin(koinApp.koin)
|
||||
logger.i("App has been setup")
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Will create [KoinApplication], init, load modules using [StartLauncherPlugin] and start plugins using the same base
|
||||
* plugin
|
||||
*
|
||||
* @param config In difference with other [start] method here config is already deserialized and this config will
|
||||
* be converted to [JsonObject] as raw config. That means that all plugins from [config] will receive
|
||||
* serialized version of [config] in [StartPlugin.setupDI] method
|
||||
*/
|
||||
suspend fun start(config: Config) {
|
||||
|
||||
logger.i("Start initialization")
|
||||
val koinApp = KoinApplication.init()
|
||||
logger.i("Koin app created")
|
||||
koinApp.modules(
|
||||
module {
|
||||
setupDI(config)
|
||||
}
|
||||
)
|
||||
startKoin(koinApp)
|
||||
logger.i("Koin started")
|
||||
startPlugin(koinApp.koin)
|
||||
|
||||
}
|
||||
}
|
||||
|
@@ -1,7 +1,7 @@
|
||||
import dev.inmo.micro_utils.startup.launcher.Config
|
||||
import dev.inmo.micro_utils.startup.launcher.HelloWorldPlugin
|
||||
import dev.inmo.micro_utils.startup.launcher.StartLauncherPlugin
|
||||
import dev.inmo.micro_utils.startup.launcher.defaultJson
|
||||
import dev.inmo.micro_utils.startup.launcher.start
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.test.runTest
|
||||
import kotlinx.serialization.json.jsonObject
|
||||
@@ -23,7 +23,7 @@ class StartupLaunchingTests {
|
||||
|
||||
runTest {
|
||||
val job = launch {
|
||||
start(emptyJson)
|
||||
StartLauncherPlugin.start(emptyJson)
|
||||
}
|
||||
job.join()
|
||||
}
|
||||
@@ -37,7 +37,7 @@ class StartupLaunchingTests {
|
||||
|
||||
runTest {
|
||||
val job = launch {
|
||||
start(emptyJson)
|
||||
StartLauncherPlugin.start(emptyJson)
|
||||
}
|
||||
job.join()
|
||||
}
|
||||
|
@@ -5,6 +5,7 @@ import dev.inmo.kslog.common.i
|
||||
import kotlinx.serialization.json.JsonObject
|
||||
import kotlinx.serialization.json.jsonObject
|
||||
|
||||
@Deprecated("Useless due to including of the same functionality in StrtLauncherPlugin")
|
||||
object PluginsStarter {
|
||||
init {
|
||||
KSLog.default = KSLog("Launcher")
|
||||
@@ -15,19 +16,10 @@ object PluginsStarter {
|
||||
* app inside of [dev.inmo.micro_utils.startup.plugin.StartPluginSerializer] using its
|
||||
* [dev.inmo.micro_utils.startup.plugin.StartPluginSerializer.registerPlugin] method
|
||||
*/
|
||||
suspend fun startPlugins(json: JsonObject) {
|
||||
start(json)
|
||||
}
|
||||
suspend fun startPlugins(json: JsonObject) = StartLauncherPlugin.start(json)
|
||||
/**
|
||||
* Will convert [config] to [JsonObject] with auto registration of [dev.inmo.micro_utils.startup.plugin.StartPlugin]s
|
||||
* in [dev.inmo.micro_utils.startup.plugin.StartPluginSerializer]
|
||||
*/
|
||||
suspend fun startPlugins(config: Config) {
|
||||
|
||||
KSLog.i("Start convert config to JSON")
|
||||
val json = defaultJson.encodeToJsonElement(Config.serializer(), config).jsonObject
|
||||
KSLog.i("Config has been read")
|
||||
|
||||
start(json)
|
||||
}
|
||||
suspend fun startPlugins(config: Config) = StartLauncherPlugin.start(config)
|
||||
}
|
||||
|
@@ -33,5 +33,5 @@ suspend fun main(args: Array<String>) {
|
||||
val json = defaultJson.parseToJsonElement(file.readText()).jsonObject
|
||||
KSLog.i("Config has been read")
|
||||
|
||||
start(json)
|
||||
StartLauncherPlugin.start(json)
|
||||
}
|
||||
|
10
startup/template/README.md
Normal file
10
startup/template/README.md
Normal file
@@ -0,0 +1,10 @@
|
||||
# How to use
|
||||
|
||||
In case you have multiplatform project and wish to use startup plugin, this template may help you to create new modules.
|
||||
|
||||
1. Copy-paste whole template folder (you may clone this folder to your project and actualize some data to copy your prepared template)
|
||||
2. Replace `group_name` by your project (or root module) group name
|
||||
3. Replace `module_name` by the name of your new module name
|
||||
|
||||
You may read about the `build.gradle` structure in these templates in project
|
||||
[KotlinMultiplatformProjectTemplate](https://github.com/InsanusMokrassar/KotlinMultiplatformProjectTemplate).
|
18
startup/template/client/build.gradle
Normal file
18
startup/template/client/build.gradle
Normal file
@@ -0,0 +1,18 @@
|
||||
plugins {
|
||||
id "org.jetbrains.kotlin.multiplatform"
|
||||
id "org.jetbrains.kotlin.plugin.serialization"
|
||||
id "com.android.library"
|
||||
alias(libs.plugins.compose)
|
||||
}
|
||||
|
||||
apply from: "$mppProjectWithSerializationPresetPath"
|
||||
|
||||
kotlin {
|
||||
sourceSets {
|
||||
commonMain {
|
||||
dependencies {
|
||||
api project(":${rootProject.name}.module_name.common")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,15 @@
|
||||
package group_name.module_name.client
|
||||
|
||||
import dev.inmo.micro_utils.startup.plugin.StartPlugin
|
||||
import kotlinx.serialization.json.JsonObject
|
||||
import org.koin.core.Koin
|
||||
import org.koin.core.module.Module
|
||||
|
||||
object ClientPlugin : StartPlugin {
|
||||
override fun Module.setupDI(config: JsonObject) {
|
||||
}
|
||||
|
||||
override suspend fun startPlugin(koin: Koin) {
|
||||
super.startPlugin(koin)
|
||||
}
|
||||
}
|
20
startup/template/client/src/jsMain/kotlin/ClientJSPlugin.kt
Normal file
20
startup/template/client/src/jsMain/kotlin/ClientJSPlugin.kt
Normal file
@@ -0,0 +1,20 @@
|
||||
package group_name.module_name.client
|
||||
|
||||
import group_name.module_name.common.CommonJSPlugin
|
||||
import dev.inmo.micro_utils.startup.plugin.StartPlugin
|
||||
import kotlinx.serialization.json.JsonObject
|
||||
import org.koin.core.Koin
|
||||
import org.koin.core.module.Module
|
||||
|
||||
object ClientJSPlugin : StartPlugin {
|
||||
override fun Module.setupDI(config: JsonObject) {
|
||||
with(CommonJSPlugin) { setupDI(config) }
|
||||
with(ClientPlugin) { setupDI(config) }
|
||||
}
|
||||
|
||||
override suspend fun startPlugin(koin: Koin) {
|
||||
super.startPlugin(koin)
|
||||
CommonJSPlugin.startPlugin(koin)
|
||||
ClientPlugin.startPlugin(koin)
|
||||
}
|
||||
}
|
@@ -0,0 +1,9 @@
|
||||
package group_name.module_name.client
|
||||
|
||||
import dev.inmo.micro_utils.startup.plugin.createStartupPluginAndRegister
|
||||
|
||||
@ExperimentalStdlibApi
|
||||
@EagerInitialization
|
||||
@JsExport
|
||||
@ExperimentalJsExport
|
||||
private val jsModuleLoader = createStartupPluginAndRegister("template.ClientJSPlugin") { ClientJSPlugin }
|
@@ -0,0 +1,21 @@
|
||||
package group_name.module_name.client
|
||||
|
||||
import group_name.module_name.common.CommonJVMPlugin
|
||||
import group_name.module_name.common.CommonJVMPlugin.setupDI
|
||||
import dev.inmo.micro_utils.startup.plugin.StartPlugin
|
||||
import kotlinx.serialization.json.JsonObject
|
||||
import org.koin.core.Koin
|
||||
import org.koin.core.module.Module
|
||||
|
||||
object ClientJVMPlugin : StartPlugin {
|
||||
override fun Module.setupDI(config: JsonObject) {
|
||||
with(CommonJVMPlugin) { setupDI(config) }
|
||||
with(ClientPlugin) { setupDI(config) }
|
||||
}
|
||||
|
||||
override suspend fun startPlugin(koin: Koin) {
|
||||
super.startPlugin(koin)
|
||||
CommonJVMPlugin.startPlugin(koin)
|
||||
ClientPlugin.startPlugin(koin)
|
||||
}
|
||||
}
|
1
startup/template/client/src/main/AndroidManifest.xml
Normal file
1
startup/template/client/src/main/AndroidManifest.xml
Normal file
@@ -0,0 +1 @@
|
||||
<manifest package="group_name.module_name.client"/>
|
@@ -0,0 +1,21 @@
|
||||
package group_name.module_name.client
|
||||
|
||||
import group_name.module_name.common.CommonAndroidPlugin
|
||||
import group_name.module_name.common.CommonAndroidPlugin.setupDI
|
||||
import dev.inmo.micro_utils.startup.plugin.StartPlugin
|
||||
import kotlinx.serialization.json.JsonObject
|
||||
import org.koin.core.Koin
|
||||
import org.koin.core.module.Module
|
||||
|
||||
object ClientAndroidPlugin : StartPlugin {
|
||||
override fun Module.setupDI(config: JsonObject) {
|
||||
with(CommonAndroidPlugin) { setupDI(config) }
|
||||
with(ClientPlugin) { setupDI(config) }
|
||||
}
|
||||
|
||||
override suspend fun startPlugin(koin: Koin) {
|
||||
super.startPlugin(koin)
|
||||
CommonAndroidPlugin.startPlugin(koin)
|
||||
ClientPlugin.startPlugin(koin)
|
||||
}
|
||||
}
|
7
startup/template/common/build.gradle
Normal file
7
startup/template/common/build.gradle
Normal file
@@ -0,0 +1,7 @@
|
||||
plugins {
|
||||
id "org.jetbrains.kotlin.multiplatform"
|
||||
id "org.jetbrains.kotlin.plugin.serialization"
|
||||
id "com.android.library"
|
||||
}
|
||||
|
||||
apply from: "$mppProjectWithSerializationPresetPath"
|
@@ -0,0 +1,11 @@
|
||||
package group_name.module_name.common
|
||||
|
||||
import dev.inmo.micro_utils.startup.plugin.StartPlugin
|
||||
import kotlinx.serialization.json.JsonObject
|
||||
import org.koin.core.module.Module
|
||||
|
||||
object CommonPlugin : StartPlugin {
|
||||
override fun Module.setupDI(config: JsonObject) {
|
||||
|
||||
}
|
||||
}
|
@@ -0,0 +1 @@
|
||||
package group_name.module_name.common
|
17
startup/template/common/src/jsMain/kotlin/CommonJSPlugin.kt
Normal file
17
startup/template/common/src/jsMain/kotlin/CommonJSPlugin.kt
Normal file
@@ -0,0 +1,17 @@
|
||||
package group_name.module_name.common
|
||||
|
||||
import dev.inmo.micro_utils.startup.plugin.StartPlugin
|
||||
import kotlinx.serialization.json.JsonObject
|
||||
import org.koin.core.Koin
|
||||
import org.koin.core.module.Module
|
||||
|
||||
object CommonJSPlugin : StartPlugin {
|
||||
override fun Module.setupDI(config: JsonObject) {
|
||||
with (CommonPlugin) { setupDI(config) }
|
||||
}
|
||||
|
||||
override suspend fun startPlugin(koin: Koin) {
|
||||
super.startPlugin(koin)
|
||||
CommonPlugin.startPlugin(koin)
|
||||
}
|
||||
}
|
@@ -0,0 +1,9 @@
|
||||
package group_name.module_name.common
|
||||
|
||||
import dev.inmo.micro_utils.startup.plugin.createStartupPluginAndRegister
|
||||
|
||||
@ExperimentalStdlibApi
|
||||
@EagerInitialization
|
||||
@JsExport
|
||||
@ExperimentalJsExport
|
||||
private val jsModuleLoader = createStartupPluginAndRegister("template.CommonJSPlugin") { CommonJSPlugin }
|
@@ -0,0 +1,17 @@
|
||||
package group_name.module_name.common
|
||||
|
||||
import dev.inmo.micro_utils.startup.plugin.StartPlugin
|
||||
import kotlinx.serialization.json.JsonObject
|
||||
import org.koin.core.Koin
|
||||
import org.koin.core.module.Module
|
||||
|
||||
object CommonJVMPlugin : StartPlugin {
|
||||
override fun Module.setupDI(config: JsonObject) {
|
||||
with (CommonPlugin) { setupDI(config) }
|
||||
}
|
||||
|
||||
override suspend fun startPlugin(koin: Koin) {
|
||||
super.startPlugin(koin)
|
||||
CommonPlugin.startPlugin(koin)
|
||||
}
|
||||
}
|
1
startup/template/common/src/main/AndroidManifest.xml
Normal file
1
startup/template/common/src/main/AndroidManifest.xml
Normal file
@@ -0,0 +1 @@
|
||||
<manifest package="group_name.module_name.common"/>
|
@@ -0,0 +1,17 @@
|
||||
package group_name.module_name.common
|
||||
|
||||
import dev.inmo.micro_utils.startup.plugin.StartPlugin
|
||||
import kotlinx.serialization.json.JsonObject
|
||||
import org.koin.core.Koin
|
||||
import org.koin.core.module.Module
|
||||
|
||||
object CommonAndroidPlugin : StartPlugin {
|
||||
override fun Module.setupDI(config: JsonObject) {
|
||||
with (CommonPlugin) { setupDI(config) }
|
||||
}
|
||||
|
||||
override suspend fun startPlugin(koin: Koin) {
|
||||
super.startPlugin(koin)
|
||||
CommonPlugin.startPlugin(koin)
|
||||
}
|
||||
}
|
16
startup/template/server/build.gradle
Normal file
16
startup/template/server/build.gradle
Normal file
@@ -0,0 +1,16 @@
|
||||
plugins {
|
||||
id "org.jetbrains.kotlin.multiplatform"
|
||||
id "org.jetbrains.kotlin.plugin.serialization"
|
||||
}
|
||||
|
||||
apply from: "$mppJavaProjectPresetPath"
|
||||
|
||||
kotlin {
|
||||
sourceSets {
|
||||
commonMain {
|
||||
dependencies {
|
||||
api project(":${rootProject.name}.module_name.common")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,15 @@
|
||||
package group_name.module_name.server
|
||||
|
||||
import dev.inmo.micro_utils.startup.plugin.StartPlugin
|
||||
import kotlinx.serialization.json.JsonObject
|
||||
import org.koin.core.Koin
|
||||
import org.koin.core.module.Module
|
||||
|
||||
object ServerPlugin : StartPlugin {
|
||||
override fun Module.setupDI(config: JsonObject) {
|
||||
}
|
||||
|
||||
override suspend fun startPlugin(koin: Koin) {
|
||||
super.startPlugin(koin)
|
||||
}
|
||||
}
|
@@ -0,0 +1,20 @@
|
||||
package group_name.module_name.server
|
||||
|
||||
import group_name.module_name.common.CommonJVMPlugin
|
||||
import dev.inmo.micro_utils.startup.plugin.StartPlugin
|
||||
import kotlinx.serialization.json.JsonObject
|
||||
import org.koin.core.Koin
|
||||
import org.koin.core.module.Module
|
||||
|
||||
object ServerJVMPlugin : StartPlugin {
|
||||
override fun Module.setupDI(config: JsonObject) {
|
||||
with(CommonJVMPlugin) { setupDI(config) }
|
||||
with(ServerPlugin) { setupDI(config) }
|
||||
}
|
||||
|
||||
override suspend fun startPlugin(koin: Koin) {
|
||||
super.startPlugin(koin)
|
||||
CommonJVMPlugin.startPlugin(koin)
|
||||
ServerPlugin.startPlugin(koin)
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user