diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index f05dfff6d..1d586c7ff 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -13,6 +13,7 @@ twelvemonkeys = "3.11.0" graphqlkotlin = "6.8.5" xmlserialization = "0.86.2" ktlint = "1.3.1" +koin-bom = "4.0.0" [libraries] # Kotlin @@ -69,13 +70,16 @@ exposed-migrations = "com.github.Suwayomi:exposed-migrations:3.2.0" # Dependency Injection kodein = "org.kodein.di:kodein-di-conf-jvm:7.20.2" +koin-bom = { module = "io.insert-koin:koin-bom", version.ref = "koin-bom" } +koin-core = { module = "io.insert-koin:koin-core" } + # tray icon systemtray-core = "com.dorkbox:SystemTray:4.4" systemtray-utils = "com.dorkbox:Utilities:1.46" # version locked by SystemTray systemtray-desktop = "com.dorkbox:Desktop:1.1" # version locked by SystemTray # dependencies of Tachiyomi extensions -injekt = "com.github.inorichi.injekt:injekt-core:65b0440" +injekt = "com.github.null2264:injekt-koin:ee267b2e27" rxjava = "io.reactivex:rxjava:1.3.8" jsoup = "org.jsoup:jsoup:1.18.1" diff --git a/server/build.gradle.kts b/server/build.gradle.kts index e682b81cf..db4070855 100644 --- a/server/build.gradle.kts +++ b/server/build.gradle.kts @@ -92,6 +92,10 @@ dependencies { implementation(libs.cron4j) implementation(libs.cronUtils) + + // koin + implementation(project.dependencies.platform(libs.koin.bom)) + implementation(libs.koin.core) } application { diff --git a/server/src/main/kotlin/eu/kanade/tachiyomi/App.kt b/server/src/main/kotlin/eu/kanade/tachiyomi/App.kt index 2962604ae..a7607737b 100644 --- a/server/src/main/kotlin/eu/kanade/tachiyomi/App.kt +++ b/server/src/main/kotlin/eu/kanade/tachiyomi/App.kt @@ -9,16 +9,15 @@ package eu.kanade.tachiyomi import android.app.Application import android.content.Context -import uy.kohesive.injekt.Injekt -import uy.kohesive.injekt.api.InjektScope -import uy.kohesive.injekt.registry.default.DefaultRegistrar +import org.koin.core.context.startKoin open class App : Application() { override fun onCreate() { super.onCreate() - Injekt = InjektScope(DefaultRegistrar()) - Injekt.importModule(AppModule(this)) + startKoin { + modules(createAppModule(this@App)) + } // if (BuildConfig.DEBUG) Timber.plant(Timber.DebugTree()) } diff --git a/server/src/main/kotlin/eu/kanade/tachiyomi/AppModule.kt b/server/src/main/kotlin/eu/kanade/tachiyomi/AppModule.kt index e193c060a..9a675b26b 100644 --- a/server/src/main/kotlin/eu/kanade/tachiyomi/AppModule.kt +++ b/server/src/main/kotlin/eu/kanade/tachiyomi/AppModule.kt @@ -24,19 +24,12 @@ import nl.adaptivity.xmlutil.serialization.XML import org.kodein.di.DI import org.kodein.di.conf.global import org.kodein.di.instance -import rx.Observable -import rx.schedulers.Schedulers -import uy.kohesive.injekt.api.InjektModule -import uy.kohesive.injekt.api.InjektRegistrar -import uy.kohesive.injekt.api.addSingleton -import uy.kohesive.injekt.api.addSingletonFactory -import uy.kohesive.injekt.api.get +import org.koin.core.module.Module +import org.koin.dsl.module -class AppModule( - val app: Application, -) : InjektModule { - override fun InjektRegistrar.registerInjectables() { - addSingleton(app) +fun createAppModule(app: Application): Module { + return module { + single { app } // addSingletonFactory { PreferencesHelper(app) } // @@ -46,9 +39,9 @@ class AppModule( // // addSingletonFactory { CoverCache(app) } - addSingletonFactory { NetworkHelper(app) } + single { NetworkHelper(app) } - addSingletonFactory { JavaScriptEngine(app) } + single { JavaScriptEngine(app) } // addSingletonFactory { SourceManager(app).also { get().init(it) } } // @@ -60,36 +53,30 @@ class AppModule( // // addSingletonFactory { LibrarySyncManager(app) } - addSingletonFactory { + single { val json by DI.global.instance() json } - addSingletonFactory { + single { val xml by DI.global.instance() xml } - addSingletonFactory { + single { val protobuf by DI.global.instance() protobuf } + } - // Asynchronously init expensive components for a faster cold start + // Asynchronously init expensive components for a faster cold start // rxAsync { get() } - rxAsync { get() } - - rxAsync { +// rxAsync { // get() // get() - } +// } // rxAsync { get() } - } - - private fun rxAsync(block: () -> Unit) { - Observable.fromCallable { block() }.subscribeOn(Schedulers.computation()).subscribe() - } }