From 0005a39eca6b0fcd9952504eea4685448c02a845 Mon Sep 17 00:00:00 2001 From: Ruslan Ibragimov Date: Mon, 11 Jan 2021 11:52:59 +0300 Subject: [PATCH] Add koin --- README.md | 3 +++ koin/build.gradle.kts | 19 +++++++++++++++++++ .../main/kotlin/org/objectstyle/koin/Main.kt | 19 +++++++++++++++++++ settings.gradle.kts | 1 + 4 files changed, 42 insertions(+) create mode 100644 koin/build.gradle.kts create mode 100644 koin/src/main/kotlin/org/objectstyle/koin/Main.kt diff --git a/README.md b/README.md index 19eef0a..af6328c 100644 --- a/README.md +++ b/README.md @@ -31,6 +31,8 @@ time (for i in {1..10}; do ./komodo/build/install/komodo/bin/komodo; done) time (for i in {1..10}; do ./owb/build/install/owb/bin/owb; done) time (for i in {1..10}; do ./spring/build/install/spring/bin/spring; done) time (for i in {1..10}; do ./springboot/build/install/springboot/bin/springboot; done) +time (for i in {1..10}; do ./koin/build/install/koin/bin/koin; done) +time (for i in {1..10}; do ./koin/build/install/koin/bin/koin; done) time (for i in {1..10}; do ./springboot/build/install/springboot/bin/springboot; done) time (for i in {1..10}; do ./spring/build/install/spring/bin/spring; done) time (for i in {1..10}; do ./owb/build/install/owb/bin/owb; done) @@ -49,6 +51,7 @@ time (for i in {1..10}; do ./baseline/build/install/baseline/bin/baseline; done) |Baseline|1.7|1.35| |Dagger|1.7|1.41| |Cayenne DI|1.8|2.05| +|Koin|1.8|2.56| |Bootique 2|4.2|4.31| |Guice|5.4|6.22| |Komodo|6.4|7.56| diff --git a/koin/build.gradle.kts b/koin/build.gradle.kts new file mode 100644 index 0000000..b57ab78 --- /dev/null +++ b/koin/build.gradle.kts @@ -0,0 +1,19 @@ +plugins { + kotlin("jvm").version("1.4.30-M1") + application +} + +application { + mainClass.set("org.objectstyle.koin.MainKt") +} + +repositories { + jcenter() +} + +dependencies { + implementation(project(":common")) + + implementation(kotlin("stdlib-jdk8")) + implementation("org.koin:koin-core:2.2.1") +} diff --git a/koin/src/main/kotlin/org/objectstyle/koin/Main.kt b/koin/src/main/kotlin/org/objectstyle/koin/Main.kt new file mode 100644 index 0000000..d271f34 --- /dev/null +++ b/koin/src/main/kotlin/org/objectstyle/koin/Main.kt @@ -0,0 +1,19 @@ +package org.objectstyle.koin + +import org.koin.dsl.koinApplication +import org.koin.dsl.module +import org.objectstyle.di.service.Service +import org.objectstyle.di.service.ServiceImpl +import org.objectstyle.di.service.SubService +import org.objectstyle.di.service.SubServiceImpl + +fun main() { + val s = koinApplication { + modules(module { + single { ServiceImpl(get()) } + single { SubServiceImpl() } + }) + }.koin.get() + + println(s.doIt()) +} diff --git a/settings.gradle.kts b/settings.gradle.kts index 19d0bcd..c04d8e4 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -1,5 +1,6 @@ include("common") include("baseline") +include("koin") include("komodo") include("bootique2") include("dagger")