diff --git a/startup/template/README.md b/startup/template/README.md new file mode 100644 index 00000000000..cf691c672f6 --- /dev/null +++ b/startup/template/README.md @@ -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). diff --git a/startup/template/client/build.gradle b/startup/template/client/build.gradle new file mode 100644 index 00000000000..55e19ae7cc0 --- /dev/null +++ b/startup/template/client/build.gradle @@ -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") + } + } + } +} diff --git a/startup/template/client/src/commonMain/kotlin/ClientPlugin.kt b/startup/template/client/src/commonMain/kotlin/ClientPlugin.kt new file mode 100644 index 00000000000..b7abfc6ff6e --- /dev/null +++ b/startup/template/client/src/commonMain/kotlin/ClientPlugin.kt @@ -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) + } +} diff --git a/startup/template/client/src/jsMain/kotlin/ClientJSPlugin.kt b/startup/template/client/src/jsMain/kotlin/ClientJSPlugin.kt new file mode 100644 index 00000000000..20a9a3bf66a --- /dev/null +++ b/startup/template/client/src/jsMain/kotlin/ClientJSPlugin.kt @@ -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) + } +} diff --git a/startup/template/client/src/jsMain/kotlin/JSModuleLoader.kt b/startup/template/client/src/jsMain/kotlin/JSModuleLoader.kt new file mode 100644 index 00000000000..ea2a24d9133 --- /dev/null +++ b/startup/template/client/src/jsMain/kotlin/JSModuleLoader.kt @@ -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 } diff --git a/startup/template/client/src/jvmMain/kotlin/ClientJVMPlugin.kt b/startup/template/client/src/jvmMain/kotlin/ClientJVMPlugin.kt new file mode 100644 index 00000000000..87f9630257b --- /dev/null +++ b/startup/template/client/src/jvmMain/kotlin/ClientJVMPlugin.kt @@ -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) + } +} diff --git a/startup/template/client/src/main/AndroidManifest.xml b/startup/template/client/src/main/AndroidManifest.xml new file mode 100644 index 00000000000..8486e9389ea --- /dev/null +++ b/startup/template/client/src/main/AndroidManifest.xml @@ -0,0 +1 @@ + diff --git a/startup/template/client/src/main/kotlin/ClientAndroidPlugin.kt b/startup/template/client/src/main/kotlin/ClientAndroidPlugin.kt new file mode 100644 index 00000000000..67938d2c4e6 --- /dev/null +++ b/startup/template/client/src/main/kotlin/ClientAndroidPlugin.kt @@ -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) + } +} diff --git a/startup/template/common/build.gradle b/startup/template/common/build.gradle new file mode 100644 index 00000000000..7c54502f100 --- /dev/null +++ b/startup/template/common/build.gradle @@ -0,0 +1,7 @@ +plugins { + id "org.jetbrains.kotlin.multiplatform" + id "org.jetbrains.kotlin.plugin.serialization" + id "com.android.library" +} + +apply from: "$mppProjectWithSerializationPresetPath" diff --git a/startup/template/common/src/commonMain/kotlin/CommonPlugin.kt b/startup/template/common/src/commonMain/kotlin/CommonPlugin.kt new file mode 100644 index 00000000000..ab808e473f2 --- /dev/null +++ b/startup/template/common/src/commonMain/kotlin/CommonPlugin.kt @@ -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) { + + } +} diff --git a/startup/template/common/src/commonMain/kotlin/Constants.kt b/startup/template/common/src/commonMain/kotlin/Constants.kt new file mode 100644 index 00000000000..84768780070 --- /dev/null +++ b/startup/template/common/src/commonMain/kotlin/Constants.kt @@ -0,0 +1 @@ +package group_name.module_name.common diff --git a/startup/template/common/src/jsMain/kotlin/CommonJSPlugin.kt b/startup/template/common/src/jsMain/kotlin/CommonJSPlugin.kt new file mode 100644 index 00000000000..f337526bdc5 --- /dev/null +++ b/startup/template/common/src/jsMain/kotlin/CommonJSPlugin.kt @@ -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) + } +} diff --git a/startup/template/common/src/jsMain/kotlin/JSModuleLoader.kt b/startup/template/common/src/jsMain/kotlin/JSModuleLoader.kt new file mode 100644 index 00000000000..875b527288f --- /dev/null +++ b/startup/template/common/src/jsMain/kotlin/JSModuleLoader.kt @@ -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 } diff --git a/startup/template/common/src/jvmMain/kotlin/CommonJVMPlugin.kt b/startup/template/common/src/jvmMain/kotlin/CommonJVMPlugin.kt new file mode 100644 index 00000000000..5afc0267b4b --- /dev/null +++ b/startup/template/common/src/jvmMain/kotlin/CommonJVMPlugin.kt @@ -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) + } +} diff --git a/startup/template/common/src/main/AndroidManifest.xml b/startup/template/common/src/main/AndroidManifest.xml new file mode 100644 index 00000000000..3ac0fa58a6f --- /dev/null +++ b/startup/template/common/src/main/AndroidManifest.xml @@ -0,0 +1 @@ + diff --git a/startup/template/common/src/main/kotlin/CommonAndroidPlugin.kt b/startup/template/common/src/main/kotlin/CommonAndroidPlugin.kt new file mode 100644 index 00000000000..a7e840d898a --- /dev/null +++ b/startup/template/common/src/main/kotlin/CommonAndroidPlugin.kt @@ -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) + } +} diff --git a/startup/template/server/build.gradle b/startup/template/server/build.gradle new file mode 100644 index 00000000000..3e0450e219b --- /dev/null +++ b/startup/template/server/build.gradle @@ -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") + } + } + } +} diff --git a/startup/template/server/src/commonMain/kotlin/ServerPlugin.kt b/startup/template/server/src/commonMain/kotlin/ServerPlugin.kt new file mode 100644 index 00000000000..7c785088e97 --- /dev/null +++ b/startup/template/server/src/commonMain/kotlin/ServerPlugin.kt @@ -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) + } +} diff --git a/startup/template/server/src/jvmMain/kotlin/ServerJVMPlugin.kt b/startup/template/server/src/jvmMain/kotlin/ServerJVMPlugin.kt new file mode 100644 index 00000000000..28c700628b4 --- /dev/null +++ b/startup/template/server/src/jvmMain/kotlin/ServerJVMPlugin.kt @@ -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) + } +}