-
Notifications
You must be signed in to change notification settings - Fork 453
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Migrating from hilt to koin (This) (#1764) * Migrating from hilt to koin * Fixed Instance creation error * refactor: Removed Hilt and migrated to Koin This commit removes Hilt and migrates the project to Koin for dependency injection. The following changes were made: - Removed the `AndroidHiltConventionPlugin`. - Added the `AndroidKoinConventionPlugin`. - Updated dependencies to use Koin. - Updated KSP configuration for Koin. - Updated feature modules to use Koin. - Updated common modules to use Koin . - Removed Hilt annotations and replaced them with Koin annotations. - Updated ViewModels to use Koin for dependency injection. - Updated modules to use Koin for dependency injection. * Formatted Dependencies * migrating from hilt to koin clean up commit * Revert "migrating from hilt to koin clean up commit" This reverts commit bb63058. --------- Co-authored-by: Sk Niyaj Ali <[email protected]> * Feat: KMP Library Setup --------- Co-authored-by: Nagarjuna <[email protected]>
- Loading branch information
1 parent
3ce0b36
commit 348ec06
Showing
316 changed files
with
4,280 additions
and
3,170 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 0 additions & 21 deletions
21
build-logic/convention/src/main/kotlin/AndroidHiltConventionPlugin.kt
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
build-logic/convention/src/main/kotlin/CMPFeatureConventionPlugin.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
|
||
import org.gradle.api.Plugin | ||
import org.gradle.api.Project | ||
import org.gradle.kotlin.dsl.dependencies | ||
import org.mifospay.libs | ||
|
||
class CMPFeatureConventionPlugin : Plugin<Project> { | ||
override fun apply(target: Project) { | ||
with(target) { | ||
pluginManager.apply { | ||
apply("mifospay.kmp.library") | ||
apply("mifospay.kmp.inject") | ||
apply("org.jetbrains.kotlin.plugin.compose") | ||
apply("org.jetbrains.compose") | ||
} | ||
|
||
dependencies { | ||
add("commonMainImplementation", project(":core:ui")) | ||
add("commonMainImplementation", project(":core:designsystem")) | ||
add("commonMainImplementation", project(":core:data")) | ||
add("commonMainImplementation", libs.findLibrary("jetbrains.compose.viewmodel").get()) | ||
add("commonMainImplementation", libs.findLibrary("jetbrains.compose.navigation").get()) | ||
add("commonMainImplementation", libs.findLibrary("kotlinx.collections.immutable").get()) | ||
|
||
add("androidMainImplementation", project(":libs:material3-navigation")) | ||
|
||
add("androidMainImplementation", libs.findLibrary("androidx.lifecycle.runtimeCompose").get()) | ||
add("androidMainImplementation", libs.findLibrary("androidx.lifecycle.viewModelCompose").get()) | ||
add("androidMainImplementation", libs.findLibrary("androidx.tracing.ktx").get()) | ||
|
||
add("androidMainImplementation", platform(libs.findLibrary("koin-bom").get())) | ||
add("androidMainImplementation", libs.findLibrary("koin-android").get()) | ||
add("androidMainImplementation", libs.findLibrary("koin.androidx.compose").get()) | ||
|
||
add("androidMainImplementation", libs.findLibrary("koin.android").get()) | ||
add("androidMainImplementation", libs.findLibrary("koin.androidx.navigation").get()) | ||
add("androidMainImplementation", libs.findLibrary("koin.androidx.compose").get()) | ||
add("androidMainImplementation", libs.findLibrary("koin.core.viewmodel").get()) | ||
|
||
add("androidTestImplementation", libs.findLibrary("koin.test.junit4").get()) | ||
|
||
add("androidDebugImplementation", libs.findLibrary("androidx.compose.ui.test.manifest").get()) | ||
add("androidInstrumentedTestImplementation", libs.findLibrary("androidx.navigation.testing").get()) | ||
add("androidInstrumentedTestImplementation", libs.findLibrary("androidx.compose.ui.test").get()) | ||
add("androidInstrumentedTestImplementation", libs.findLibrary("androidx.lifecycle.runtimeTesting").get()) | ||
add("androidInstrumentedTestImplementation", libs.findLibrary("androidx.test.core").get()) | ||
add("androidInstrumentedTestImplementation", libs.findLibrary("androidx.test.ext").get()) | ||
add("androidInstrumentedTestImplementation", libs.findLibrary("androidx.test.junit").get()) | ||
add("androidInstrumentedTestImplementation", libs.findLibrary("androidx.test.runner").get()) | ||
add("androidInstrumentedTestImplementation", libs.findLibrary("androidx.test.espresso.core").get()) | ||
} | ||
} | ||
} | ||
} |
40 changes: 40 additions & 0 deletions
40
build-logic/convention/src/main/kotlin/KMPKoinConventionPlugin.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import com.google.devtools.ksp.gradle.KspExtension | ||
import org.gradle.api.Plugin | ||
import org.gradle.api.Project | ||
import org.gradle.kotlin.dsl.configure | ||
import org.gradle.kotlin.dsl.dependencies | ||
import org.mifospay.libs | ||
|
||
|
||
class KMPKoinConventionPlugin : Plugin<Project> { | ||
override fun apply(target: Project) { | ||
with(target) { | ||
with(pluginManager) { | ||
apply("com.google.devtools.ksp") | ||
} | ||
|
||
dependencies { | ||
val bom = libs.findLibrary("koin-bom").get() | ||
add("commonMainImplementation", platform(bom)) | ||
add("commonMainImplementation", libs.findLibrary("koin.core").get()) | ||
|
||
add("commonMainImplementation", libs.findLibrary("koin.annotations").get()) | ||
add("kspCommonMainMetadata", libs.findLibrary("koin.ksp.compiler").get()) | ||
add("ksp", libs.findLibrary("koin.ksp.compiler").get()) | ||
// add("kspWasmJs", libs.findLibrary("koin.ksp.compiler").get()) | ||
// add("kspJvm", libs.findLibrary("koin.ksp.compiler").get()) | ||
// add("kspIosX64", libs.findLibrary("koin.ksp.compiler").get()) | ||
// add("kspIosArm64", libs.findLibrary("koin.ksp.compiler").get()) | ||
// add("kspIosSimulatorArm64", libs.findLibrary("koin.ksp.compiler").get()) | ||
|
||
add("commonTestImplementation", libs.findLibrary("koin.test").get()) | ||
} | ||
|
||
extensions.configure<KspExtension> { | ||
arg("KOIN_CONFIG_CHECK","true") | ||
arg("USE_COMPOSE_VIEWMODEL", "false") | ||
arg("KOIN_USE_COMPOSE_VIEWMODEL", "true") | ||
} | ||
} | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
build-logic/convention/src/main/kotlin/KMPLibraryConventionPlugin.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
|
||
import com.android.build.gradle.LibraryExtension | ||
import org.gradle.api.Plugin | ||
import org.gradle.api.Project | ||
import org.gradle.kotlin.dsl.configure | ||
import org.gradle.kotlin.dsl.dependencies | ||
import org.mifospay.configureFlavors | ||
import org.mifospay.configureKotlinAndroid | ||
import org.mifospay.configureKotlinMultiplatform | ||
import org.mifospay.libs | ||
|
||
class KMPLibraryConventionPlugin: Plugin<Project> { | ||
override fun apply(target: Project) { | ||
with(target) { | ||
with(pluginManager) { | ||
apply("com.android.library") | ||
apply("org.jetbrains.kotlin.multiplatform") | ||
apply("mifospay.kmp.koin") | ||
apply("mifos.detekt.plugin") | ||
apply("mifos.spotless.plugin") | ||
apply("mifos.ktlint.plugin") | ||
} | ||
|
||
configureKotlinMultiplatform() | ||
|
||
extensions.configure<LibraryExtension> { | ||
configureKotlinAndroid(this) | ||
defaultConfig.targetSdk = 34 | ||
configureFlavors(this) | ||
// The resource prefix is derived from the module name, | ||
// so resources inside ":core:module1" must be prefixed with "core_module1_" | ||
resourcePrefix = path.split("""\W""".toRegex()).drop(1).distinct().joinToString(separator = "_").lowercase() + "_" | ||
} | ||
|
||
dependencies { | ||
add("commonTestImplementation", libs.findLibrary("kotlin.test").get()) | ||
add("commonTestImplementation", libs.findLibrary("kotlinx.coroutines.test").get()) | ||
} | ||
} | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
build-logic/convention/src/main/kotlin/KoinConventionPlugin.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import com.google.devtools.ksp.gradle.KspExtension | ||
import org.gradle.api.Plugin | ||
import org.gradle.api.Project | ||
import org.gradle.kotlin.dsl.configure | ||
import org.gradle.kotlin.dsl.dependencies | ||
import org.mifospay.libs | ||
|
||
|
||
class KoinConventionPlugin : Plugin<Project> { | ||
override fun apply(target: Project) { | ||
with(target) { | ||
with(pluginManager) { | ||
apply("com.google.devtools.ksp") | ||
} | ||
|
||
dependencies { | ||
val bom = libs.findLibrary("koin-bom").get() | ||
add("implementation", platform(bom)) | ||
add("implementation", libs.findLibrary("koin.core").get()) | ||
|
||
add("implementation", libs.findLibrary("koin.annotations").get()) | ||
add("ksp", libs.findLibrary("koin.ksp.compiler").get()) | ||
|
||
|
||
add("testImplementation", libs.findLibrary("koin.test").get()) | ||
add("testImplementation", libs.findLibrary("koin.test.junit4").get()) | ||
} | ||
|
||
extensions.configure<KspExtension> { | ||
arg("KOIN_CONFIG_CHECK","true") | ||
arg("USE_COMPOSE_VIEWMODEL", "false") | ||
arg("KOIN_USE_COMPOSE_VIEWMODEL", "true") | ||
} | ||
} | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
build-logic/convention/src/main/kotlin/KotlinInjectConventionPlugin.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import org.gradle.api.Plugin | ||
import org.gradle.api.Project | ||
import org.gradle.kotlin.dsl.dependencies | ||
import org.mifospay.libs | ||
|
||
class KotlinInjectConventionPlugin: Plugin<Project> { | ||
override fun apply(target: Project) { | ||
with(target) { | ||
with(pluginManager) { | ||
apply("com.google.devtools.ksp") | ||
} | ||
dependencies { | ||
add("kspCommonMainMetadata", libs.findLibrary("kotlin.inject.compiler.ksp").get()) | ||
add("commonMainImplementation", libs.findLibrary("kotlin.inject.runtime.kmp").get()) | ||
// KSP will eventually have better multiplatform support and we'll be able to simply have | ||
// `ksp libs.kotlinInject.compiler` in the dependencies block of each source set | ||
// https://github.com/google/ksp/pull/1021 | ||
add("kspIosX64", libs.findLibrary("kotlin.inject.compiler.ksp").get()) | ||
add("kspIosArm64", libs.findLibrary("kotlin.inject.compiler.ksp").get()) | ||
add("kspIosSimulatorArm64", libs.findLibrary("kotlin.inject.compiler.ksp").get()) | ||
// add("kspWasmJs", libs.findLibrary("kotlin.inject.compiler.ksp").get()) | ||
add("kspAndroid", libs.findLibrary("kotlin.inject.compiler.ksp").get()) | ||
add("kspJvm", libs.findLibrary("kotlin.inject.compiler.ksp").get()) | ||
add("kspMacosX64", libs.findLibrary("kotlin.inject.compiler.ksp").get()) | ||
add("kspMacosArm64", libs.findLibrary("kotlin.inject.compiler.ksp").get()) | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.