diff --git a/core/build.gradle.kts b/core/build.gradle.kts index 9341426560..937662ecbe 100644 --- a/core/build.gradle.kts +++ b/core/build.gradle.kts @@ -33,7 +33,9 @@ kotlin { androidMain { dependencies { // Dependency injection - api(projects.injektKoin) + api(project.dependencies.platform(libs.koin.bom)) + api(libs.koin.core) + api(libs.koin.injekt) // Network client api(libs.okhttp) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index af378d74dc..0eb31bdf59 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -42,12 +42,12 @@ flexbox = { module = "com.google.android.flexbox:flexbox", version = "3.0.0" } flexible-adapter-ui = { module = "com.github.arkon.FlexibleAdapter:flexible-adapter-ui", version.ref = "flexible-adapter" } flexible-adapter = { module = "com.github.arkon.FlexibleAdapter:flexible-adapter", version.ref = "flexible-adapter" } image-decoder = { module = "com.github.tachiyomiorg:image-decoder", version = "41c059e540" } -injekt-core = { module = "com.github.null2264.injekt:injekt-core", version = "4135455a2a" } kermit = { module = "co.touchlab:kermit", version.ref = "kermit" } koin-bom = { module = "io.insert-koin:koin-bom", version.ref = "koin" } koin-core = { module = "io.insert-koin:koin-core" } +koin-injekt = { module = "com.github.null2264:injekt-koin", version = "7f944dd775" } kotest-assertions = { module = "io.kotest:kotest-assertions-core", version = "5.9.1" } diff --git a/injekt-koin/build.gradle.kts b/injekt-koin/build.gradle.kts deleted file mode 100644 index f84f622f58..0000000000 --- a/injekt-koin/build.gradle.kts +++ /dev/null @@ -1,38 +0,0 @@ -import org.jetbrains.kotlin.gradle.tasks.KotlinCompile - -plugins { - alias(androidx.plugins.library) - alias(kotlinx.plugins.multiplatform) - alias(kotlinx.plugins.serialization) -} - -kotlin { - androidTarget() - sourceSets { - val commonMain by getting { - dependencies { - api(project.dependencies.platform(libs.koin.bom)) - api(libs.koin.core) - } - } - val androidMain by getting { - dependencies { - } - } - } -} - -android { - namespace = "uy.kohesive.injekt" - defaultConfig { - consumerProguardFile("consumer-proguard.pro") - } -} - -tasks { - withType { - compilerOptions.freeCompilerArgs.addAll( - "-Xexpect-actual-classes", - ) - } -} diff --git a/injekt-koin/consumer-proguard.pro b/injekt-koin/consumer-proguard.pro deleted file mode 100644 index f6712ff958..0000000000 --- a/injekt-koin/consumer-proguard.pro +++ /dev/null @@ -1 +0,0 @@ --keep,allowoptimization class uy.kohesive.injekt.** { public protected *; } diff --git a/injekt-koin/src/commonMain/kotlin/uy/kohesive/injekt/Injekt.kt b/injekt-koin/src/commonMain/kotlin/uy/kohesive/injekt/Injekt.kt deleted file mode 100644 index a68ac7485e..0000000000 --- a/injekt-koin/src/commonMain/kotlin/uy/kohesive/injekt/Injekt.kt +++ /dev/null @@ -1,9 +0,0 @@ -package uy.kohesive.injekt - -import uy.kohesive.injekt.api.InjektScope -import uy.kohesive.injekt.api.fullType - -@Volatile var Injekt: InjektScope = InjektScope() - -@Suppress("unused") -inline fun injectLazy(): Lazy = lazy { Injekt.getInstance(fullType().type) } diff --git a/injekt-koin/src/commonMain/kotlin/uy/kohesive/injekt/api/InjektFactory.kt b/injekt-koin/src/commonMain/kotlin/uy/kohesive/injekt/api/InjektFactory.kt deleted file mode 100644 index 9e072cb5a0..0000000000 --- a/injekt-koin/src/commonMain/kotlin/uy/kohesive/injekt/api/InjektFactory.kt +++ /dev/null @@ -1,27 +0,0 @@ -package uy.kohesive.injekt.api - -import java.lang.reflect.Type -import org.koin.core.parameter.ParametersDefinition -import org.koin.core.qualifier.Qualifier - -interface InjektFactory { - fun getInstance(forType: Type): R - /* - fun getInstanceOrElse(forType: Type, default: R): R - fun getInstanceOrElse(forType: Type, default: ()->R): R - */ - fun getInstanceOrNull(forType: Type): R? - - /* - fun getKeyedInstance(forType: Type, key: K): R - fun getKeyedInstanceOrElse(forType: Type, key: K, default: R): R - fun getKeyedInstanceOrElse(forType: Type, key: K, default: ()->R): R - fun getKeyedInstanceOrNull(forType: Type, key: K): R? - */ -} - -@Suppress("unused") -inline fun InjektFactory.get( - qualifier: Qualifier? = null, - noinline parameters: ParametersDefinition? = null, -): T = getInstance(fullType().type) diff --git a/injekt-koin/src/commonMain/kotlin/uy/kohesive/injekt/api/InjektScope.kt b/injekt-koin/src/commonMain/kotlin/uy/kohesive/injekt/api/InjektScope.kt deleted file mode 100644 index 60b8341393..0000000000 --- a/injekt-koin/src/commonMain/kotlin/uy/kohesive/injekt/api/InjektScope.kt +++ /dev/null @@ -1,13 +0,0 @@ -package uy.kohesive.injekt.api - -import java.lang.reflect.Type -import org.koin.mp.KoinPlatformTools - -class InjektScope : InjektFactory { - - override fun getInstance(forType: Type): R = - KoinPlatformTools.defaultContext().get().get(forType.kotlinClass) - - override fun getInstanceOrNull(forType: Type): R? = - KoinPlatformTools.defaultContext().getOrNull()?.getOrNull(forType.kotlinClass) -} diff --git a/injekt-koin/src/commonMain/kotlin/uy/kohesive/injekt/api/InjektTypeInfo.kt b/injekt-koin/src/commonMain/kotlin/uy/kohesive/injekt/api/InjektTypeInfo.kt deleted file mode 100644 index 60570d104b..0000000000 --- a/injekt-koin/src/commonMain/kotlin/uy/kohesive/injekt/api/InjektTypeInfo.kt +++ /dev/null @@ -1,44 +0,0 @@ -package uy.kohesive.injekt.api - -import java.lang.reflect.GenericArrayType -import java.lang.reflect.ParameterizedType -import java.lang.reflect.Type -import java.lang.reflect.TypeVariable -import java.lang.reflect.WildcardType - -@Suppress("UNCHECKED_CAST") fun Type.erasedType(): Class { - return when (this) { - is Class<*> -> this as Class - is ParameterizedType -> this.rawType.erasedType() - is GenericArrayType -> { - val elementType = this.genericComponentType.erasedType() - val testArray = java.lang.reflect.Array.newInstance(elementType, 0) - testArray.javaClass - } - is TypeVariable<*> -> { - throw IllegalStateException("Not sure what to do here yet") - } - is WildcardType -> { - this.upperBounds[0].erasedType() - } - else -> throw IllegalStateException("Should not get here.") - } -} - -val Type.kotlinClass get() = erasedType().kotlin - -inline fun typeRef(): FullTypeReference = object : FullTypeReference() {} -inline fun fullType(): FullTypeReference = object : FullTypeReference() {} - -interface TypeReference { - val type: Type -} - -abstract class FullTypeReference protected constructor() : TypeReference { - override val type: Type = javaClass.getGenericSuperclass().let { superClass -> - if (superClass is Class<*>) { - throw IllegalArgumentException("Internal error: TypeReference constructed without actual type information") - } - (superClass as ParameterizedType).actualTypeArguments[0] - } -} diff --git a/settings.gradle.kts b/settings.gradle.kts index af10f53b49..1c0f8209f0 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -35,7 +35,6 @@ include(":core") include(":data") include(":domain") include(":i18n") -include(":injekt-koin") include(":presentation:core") //include(":presentation:widget") include(":source:api") diff --git a/source/api/build.gradle.kts b/source/api/build.gradle.kts index ab4d23cc4d..8d6fe1986a 100644 --- a/source/api/build.gradle.kts +++ b/source/api/build.gradle.kts @@ -12,7 +12,9 @@ kotlin { val commonMain by getting { dependencies { api(kotlinx.serialization.json) - api(projects.injektKoin) + api(project.dependencies.platform(libs.koin.bom)) + api(libs.koin.core) + api(libs.koin.injekt) api(libs.rxjava) api(libs.jsoup) }