refactor: migrate from Hilt to Koin and expand KMP common modules (#4746)

Signed-off-by: James Rich <2199651+jamesarich@users.noreply.github.com>
This commit is contained in:
James Rich 2026-03-09 20:19:46 -05:00 committed by GitHub
parent a5390a80e7
commit 875cf1cff2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
440 changed files with 3738 additions and 3508 deletions

View file

@ -52,7 +52,7 @@ dependencies {
compileOnly(libs.dokka.gradlePlugin)
compileOnly(libs.firebase.crashlytics.gradlePlugin)
compileOnly(libs.google.services.gradlePlugin)
compileOnly(libs.hilt.gradlePlugin)
compileOnly(libs.koin.gradlePlugin)
implementation(libs.kover.gradlePlugin)
compileOnly(libs.kotlin.gradlePlugin)
compileOnly(libs.ksp.gradlePlugin)
@ -144,9 +144,9 @@ gradlePlugin {
id = "meshtastic.analytics"
implementationClass = "AnalyticsConventionPlugin"
}
register("meshtasticHilt") {
id = "meshtastic.hilt"
implementationClass = "HiltConventionPlugin"
register("meshtasticKoin") {
id = "meshtastic.koin"
implementationClass = "KoinConventionPlugin"
}
register("meshtasticDetekt") {
id = "meshtastic.detekt"

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2025 Meshtastic LLC
* Copyright (c) 2026 Meshtastic LLC
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -19,33 +19,31 @@ import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.kotlin.dsl.apply
import org.gradle.kotlin.dsl.dependencies
import org.meshtastic.buildlogic.library
import org.meshtastic.buildlogic.libs
import org.meshtastic.buildlogic.plugin
class HiltConventionPlugin : Plugin<Project> {
class KoinConventionPlugin : Plugin<Project> {
override fun apply(target: Project) {
with(target) {
apply(plugin = "com.google.devtools.ksp")
apply(plugin = libs.plugin("koin-compiler").get().pluginId)
dependencies {
"ksp"(libs.library("hilt-compiler"))
"implementation"(libs.library("hilt-android"))
}
val koinAnnotations = libs.findLibrary("koin-annotations").get()
val koinCore = libs.findLibrary("koin-core").get()
// Add support for Jvm Module, base on org.jetbrains.kotlin.jvm
pluginManager.withPlugin("org.jetbrains.kotlin.jvm") {
pluginManager.withPlugin("org.jetbrains.kotlin.multiplatform") {
dependencies {
"implementation"(libs.library("hilt-core"))
add("commonMainApi", koinCore)
add("commonMainApi", koinAnnotations)
}
}
pluginManager.withPlugin("com.android.base") {
apply(plugin = "dagger.hilt.android.plugin")
}
pluginManager.withPlugin("org.jetbrains.kotlin.plugin.compose") {
dependencies {
"implementation"(libs.library("androidx-hilt-lifecycle-viewmodel-compose"))
pluginManager.withPlugin("org.jetbrains.kotlin.android") {
// If this is *only* an Android module (no KMP plugin)
if (!pluginManager.hasPlugin("org.jetbrains.kotlin.multiplatform")) {
dependencies {
add("implementation", koinCore)
add("implementation", koinAnnotations)
}
}
}
}

View file

@ -29,7 +29,7 @@ fun Project.configureDokka() {
dokkaSourceSets.configureEach {
perPackageOption {
matchingRegex.set("hilt_aggregated_deps")
matchingRegex.set("koin_aggregated_deps")
suppress.set(true)
}
perPackageOption {

View file

@ -47,8 +47,6 @@ fun Project.configureKover() {
// Exclude declarations
annotatedBy(
"*.HiltAndroidApp",
"*.AndroidEntryPoint",
"*.Module",
"*.Provides",
"*.Binds",
@ -56,7 +54,7 @@ fun Project.configureKover() {
)
// Suppress generated code
packages("hilt_aggregated_deps")
packages("koin_aggregated_deps")
packages("org.meshtastic.core.resources")
}
}