-
Notifications
You must be signed in to change notification settings - Fork 54
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Migrate Dependency Injection Framework from Hilt to Koin #237
base: kmp
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,30 @@ | ||
package ir.composenews | ||
|
||
import android.app.Application | ||
import dagger.hilt.android.HiltAndroidApp | ||
import ir.composenews.data.di.repositoryModule | ||
import ir.composenews.marketdetail.marketDetailFeatureModule | ||
import ir.composenews.marketlist.marketListFeatureModule | ||
import org.koin.android.ext.koin.androidContext | ||
import org.koin.android.ext.koin.androidLogger | ||
import org.koin.core.context.GlobalContext.startKoin | ||
import org.koin.core.logger.Level | ||
|
||
@HiltAndroidApp | ||
class ComposeNewsWearApplication : Application() | ||
class ComposeNewsWearApplication : Application() { | ||
override fun onCreate() { | ||
super.onCreate() | ||
|
||
startKoin { | ||
androidContext(this@ComposeNewsWearApplication) | ||
androidLogger(Level.DEBUG) | ||
|
||
modules( | ||
listOf( | ||
mainViewModelModule, | ||
marketListFeatureModule, marketDetailFeatureModule, | ||
|
||
repositoryModule, | ||
) | ||
) | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package ir.composenews | ||
|
||
import org.koin.androidx.viewmodel.dsl.viewModel | ||
import org.koin.dsl.module | ||
|
||
val mainViewModelModule =module { | ||
viewModel { | ||
MainViewModel(get())} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,7 +9,7 @@ android { | |
|
||
dependencies { | ||
projects.apply { | ||
implementation(appWatch.ui) | ||
api(appWatch.ui) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why do you make it |
||
implementation(core.uimarket) | ||
} | ||
implementation(libs.navigation.compose.wear) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
plugins { | ||
id("composenews.android.feature") | ||
id("composenews.android.koin") | ||
} | ||
|
||
android { | ||
|
@@ -14,8 +15,8 @@ configurations.all { | |
|
||
dependencies { | ||
projects.apply { | ||
implementation(feature.marketlist) | ||
implementation(feature.marketdetail) | ||
api(feature.marketlist) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. And Why |
||
api(feature.marketdetail) | ||
implementation(core.uimarket) | ||
implementation(core.extensions) | ||
implementation(data.marketRepository) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -44,11 +44,6 @@ | |
|
||
-keep class * extends androidx.compose.runtime.Composable { *; } | ||
|
||
-keepclassmembers class * { | ||
@dagger.hilt.android.lifecycle.HiltViewModel *; | ||
} | ||
-keep,@dagger.hilt.InstallIn class * { *; } | ||
-keep class dagger.hilt.** { *; } | ||
-dontwarn dagger.internal.codegen.ComponentProcessor | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we remove this line too? |
||
|
||
-keep class retrofit2.** { *; } | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,31 @@ | ||
package ir.composenews | ||
|
||
import android.app.Application | ||
import dagger.hilt.android.HiltAndroidApp | ||
import ir.composenews.data.di.repositoryModule | ||
import ir.composenews.marketdetail.marketDetailFeatureModule | ||
import ir.composenews.marketlist.marketListFeatureModule | ||
import ir.composenews.sync.Sync | ||
import org.koin.android.ext.koin.androidContext | ||
import org.koin.android.ext.koin.androidLogger | ||
import org.koin.core.context.startKoin | ||
import org.koin.core.logger.Level | ||
|
||
@HiltAndroidApp | ||
class ComposeNewsApplication : Application() { | ||
|
||
override fun onCreate() { | ||
super.onCreate() | ||
Sync.init(this) | ||
} | ||
|
||
startKoin { | ||
androidContext(this@ComposeNewsApplication) | ||
androidLogger(Level.DEBUG) | ||
|
||
modules( | ||
listOf( | ||
marketListFeatureModule, marketDetailFeatureModule, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Break this line into two lines |
||
repositoryModule, | ||
) | ||
) | ||
} | ||
} | ||
} |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import ir.composenews.libs | ||
import org.gradle.api.Plugin | ||
import org.gradle.api.Project | ||
import org.gradle.kotlin.dsl.dependencies | ||
|
||
class KoinConventionPlugin : Plugin<Project> { | ||
override fun apply(target: Project) { | ||
target.run { | ||
applyDependencies() | ||
} | ||
} | ||
|
||
private fun Project.applyPlugins() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this function can be removed. |
||
pluginManager.apply { | ||
// apply("org.jetbrains.kotlin.kapt") | ||
} | ||
} | ||
|
||
private fun Project.applyDependencies() { | ||
dependencies { | ||
"implementation"(libs.findBundle("koin").get()) | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,10 +4,8 @@ plugins { | |
alias(kotlin.parcelize) apply false | ||
alias(android.library) apply false | ||
alias(kotlin.android) apply false | ||
alias(hilt.android) apply false | ||
alias(kotliner) apply false | ||
alias(detekt) apply false | ||
// alias(ksp) apply false | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please put back this comment. We are currently working on an issue about |
||
alias(compose) apply false | ||
} | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Break it into two lines.