From bef2140b101c984f2b994a8bb83f611c348853e3 Mon Sep 17 00:00:00 2001 From: hsgo2430 Date: Mon, 1 Apr 2024 00:39:21 +0900 Subject: [PATCH] =?UTF-8?q?di=20=EB=AA=A8=EB=93=88=20=EB=B6=84=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...droidApplicationComposeConventionPlugin.kt | 1 + business/KoinBusinessApplication.kt | 5 +++ business/build.gradle.kts | 5 ++- business/src/main/AndroidManifest.xml | 4 +- .../business/KoinBusinessApplication.kt | 7 ++++ .../business/di/network/AuthNetworkModule.kt | 14 +++---- .../business/di/network/NetworkModule.kt | 42 ------------------- .../di/network/NoAuthNetworkModule.kt | 23 ---------- .../di/repository/RepositoryModule.kt | 22 ---------- .../PasswordAuthenticationScreen.kt | 5 ++- core/build.gradle | 2 + .../core}/di/CoroutineDispatchersModule.kt | 2 +- data/build.gradle | 1 + .../koin/data}/di/error/ErrorHandlerModule.kt | 2 +- .../koin/data}/di/network/NetworkModule.kt | 15 +++---- .../data}/di/network/NoAuthNetworkModule.kt | 2 +- .../data}/di/repository/RepositoryModule.kt | 4 +- .../data}/di/source/LocalDataSourceModule.kt | 8 +++- .../data}/di/source/RemoteDataSourceModule.kt | 4 +- gradle/libs.versions.toml | 3 ++ koin/build.gradle | 1 + 21 files changed, 55 insertions(+), 117 deletions(-) create mode 100644 business/KoinBusinessApplication.kt create mode 100644 business/src/main/java/in/koreatech/business/KoinBusinessApplication.kt delete mode 100644 business/src/main/java/in/koreatech/business/di/network/NetworkModule.kt delete mode 100644 business/src/main/java/in/koreatech/business/di/network/NoAuthNetworkModule.kt delete mode 100644 business/src/main/java/in/koreatech/business/di/repository/RepositoryModule.kt rename {koin/src/main/java/in/koreatech/koin => core/src/main/java/in/koreatech/koin/core}/di/CoroutineDispatchersModule.kt (96%) rename {koin/src/main/java/in/koreatech/koin => data/src/main/java/in/koreatech/koin/data}/di/error/ErrorHandlerModule.kt (97%) rename {koin/src/main/java/in/koreatech/koin => data/src/main/java/in/koreatech/koin/data}/di/network/NetworkModule.kt (75%) rename {koin/src/main/java/in/koreatech/koin => data/src/main/java/in/koreatech/koin/data}/di/network/NoAuthNetworkModule.kt (98%) rename {koin/src/main/java/in/koreatech/koin => data/src/main/java/in/koreatech/koin/data}/di/repository/RepositoryModule.kt (98%) rename {koin/src/main/java/in/koreatech/koin => data/src/main/java/in/koreatech/koin/data}/di/source/LocalDataSourceModule.kt (80%) rename {koin/src/main/java/in/koreatech/koin => data/src/main/java/in/koreatech/koin/data}/di/source/RemoteDataSourceModule.kt (98%) diff --git a/build-logic/convention/src/main/java/AndroidApplicationComposeConventionPlugin.kt b/build-logic/convention/src/main/java/AndroidApplicationComposeConventionPlugin.kt index 848395b34..3a2ea5c6d 100644 --- a/build-logic/convention/src/main/java/AndroidApplicationComposeConventionPlugin.kt +++ b/build-logic/convention/src/main/java/AndroidApplicationComposeConventionPlugin.kt @@ -10,6 +10,7 @@ internal class AndroidApplicationComposeConventionPlugin : Plugin { with(pluginManager) { apply("com.android.application") apply("org.jetbrains.kotlin.android") + apply("kotlin-kapt") } extensions.configure { configureAndroidCompose(this) diff --git a/business/KoinBusinessApplication.kt b/business/KoinBusinessApplication.kt new file mode 100644 index 000000000..1eb79f04e --- /dev/null +++ b/business/KoinBusinessApplication.kt @@ -0,0 +1,5 @@ +import android.app.Application + +@HiltAndroidApp +class KoinBusinessApplication: Application() { +} \ No newline at end of file diff --git a/business/build.gradle.kts b/business/build.gradle.kts index 3a71e70f5..f7c22e8c2 100644 --- a/business/build.gradle.kts +++ b/business/build.gradle.kts @@ -1,3 +1,5 @@ +import `in`.koreatech.convention.kapt + @Suppress("DSL_SCOPE_VIOLATION") plugins { alias(libs.plugins.koin.compose) @@ -34,7 +36,8 @@ dependencies { implementation(libs.orbit.core) implementation(libs.orbit.viewmodel) implementation(libs.hilt.android) - implementation(libs.hilt.compiler) + implementation(libs.hilt.compose) + kapt(libs.hilt.compiler) implementation(project(mapOf("path" to ":domain"))) implementation(project(mapOf("path" to ":data"))) implementation(project(mapOf("path" to ":core"))) diff --git a/business/src/main/AndroidManifest.xml b/business/src/main/AndroidManifest.xml index d89928d6c..6e2efa362 100644 --- a/business/src/main/AndroidManifest.xml +++ b/business/src/main/AndroidManifest.xml @@ -2,8 +2,8 @@ - - + Unit, onBackPressed: () -> Unit, - viewModel: PasswordAuthenticationViewModel = viewModel() + viewModel: PasswordAuthenticationViewModel = hiltViewModel() ) { val state = viewModel.collectAsState().value val context = LocalContext.current @@ -165,7 +166,7 @@ fun PasswordAuthenticationScreen( ) Button( - onClick = { /*viewModel.sendAuthCode(state.email)*/ }, + onClick = { viewModel.sendAuthCode(state.email) }, shape = RectangleShape, colors = ButtonDefaults.buttonColors(ColorPrimary), contentPadding = PaddingValues(1.dp), diff --git a/core/build.gradle b/core/build.gradle index d29095ea3..e3af6ce5f 100644 --- a/core/build.gradle +++ b/core/build.gradle @@ -3,6 +3,7 @@ plugins { id 'kotlin-android' id 'kotlin-kapt' id 'com.google.dagger.hilt.android' + id 'org.jetbrains.kotlin.android' } android { @@ -46,6 +47,7 @@ android { } dependencies { + implementation 'androidx.core:core-ktx:+' androidTestImplementation('androidx.test.espresso:espresso-core:3.1.0', { exclude group: 'com.android.support', module: 'support-annotations' exclude group: 'com.google.code.findbugs' diff --git a/koin/src/main/java/in/koreatech/koin/di/CoroutineDispatchersModule.kt b/core/src/main/java/in/koreatech/koin/core/di/CoroutineDispatchersModule.kt similarity index 96% rename from koin/src/main/java/in/koreatech/koin/di/CoroutineDispatchersModule.kt rename to core/src/main/java/in/koreatech/koin/core/di/CoroutineDispatchersModule.kt index b6ec11c07..f7813eb18 100644 --- a/koin/src/main/java/in/koreatech/koin/di/CoroutineDispatchersModule.kt +++ b/core/src/main/java/in/koreatech/koin/core/di/CoroutineDispatchersModule.kt @@ -1,4 +1,4 @@ -package `in`.koreatech.koin.di +package `in`.koreatech.koin.core.di import dagger.Module import dagger.Provides diff --git a/data/build.gradle b/data/build.gradle index 9aa7e6202..efca3e0ba 100644 --- a/data/build.gradle +++ b/data/build.gradle @@ -41,6 +41,7 @@ android { dependencies { implementation project(':domain') + implementation project(':core') implementation libs.core.ktx implementation libs.kotlinx.coroutines.android diff --git a/koin/src/main/java/in/koreatech/koin/di/error/ErrorHandlerModule.kt b/data/src/main/java/in/koreatech/koin/data/di/error/ErrorHandlerModule.kt similarity index 97% rename from koin/src/main/java/in/koreatech/koin/di/error/ErrorHandlerModule.kt rename to data/src/main/java/in/koreatech/koin/data/di/error/ErrorHandlerModule.kt index b652a94e2..a8530f112 100644 --- a/koin/src/main/java/in/koreatech/koin/di/error/ErrorHandlerModule.kt +++ b/data/src/main/java/in/koreatech/koin/data/di/error/ErrorHandlerModule.kt @@ -1,4 +1,4 @@ -package `in`.koreatech.koin.di.error +package `in`.koreatech.koin.data.di.error import `in`.koreatech.koin.data.error.BusErrorHandlerImpl import `in`.koreatech.koin.data.error.DeptErrorHandlerImpl diff --git a/koin/src/main/java/in/koreatech/koin/di/network/NetworkModule.kt b/data/src/main/java/in/koreatech/koin/data/di/network/NetworkModule.kt similarity index 75% rename from koin/src/main/java/in/koreatech/koin/di/network/NetworkModule.kt rename to data/src/main/java/in/koreatech/koin/data/di/network/NetworkModule.kt index 5e0ba27ab..f84abd4c1 100644 --- a/koin/src/main/java/in/koreatech/koin/di/network/NetworkModule.kt +++ b/data/src/main/java/in/koreatech/koin/data/di/network/NetworkModule.kt @@ -1,8 +1,7 @@ -package `in`.koreatech.koin.di.network +package `in`.koreatech.koin.data.di.network import `in`.koreatech.koin.core.qualifier.ServerUrl import `in`.koreatech.koin.data.constant.URLConstant -import `in`.koreatech.koin.util.ext.isDebug import android.content.Context import android.util.Log import dagger.Module @@ -10,6 +9,8 @@ import dagger.Provides import dagger.hilt.InstallIn import dagger.hilt.android.qualifiers.ApplicationContext import dagger.hilt.components.SingletonComponent +import `in`.koreatech.koin.data.BuildConfig +//import `in`.koreatech.koin.domain.util.ext.isDebug import javax.inject.Singleton import okhttp3.logging.HttpLoggingInterceptor @@ -19,9 +20,9 @@ object NetworkModule { @Provides @Singleton fun provideHttpLoggingInterceptor( - @ApplicationContext applicationContext: Context + ) = HttpLoggingInterceptor().apply { - level = if (applicationContext.isDebug) { + level = if (BuildConfig.DEBUG) { HttpLoggingInterceptor.Level.BODY } else { HttpLoggingInterceptor.Level.HEADERS @@ -32,12 +33,12 @@ object NetworkModule { @Provides @Singleton fun provideServerUrl( - @ApplicationContext applicationContext: Context + ): String { - return if (applicationContext.isDebug) { + return if (BuildConfig.DEBUG) { URLConstant.BASE_URL_STAGE } else { URLConstant.BASE_URL_PRODUCTION } } -} \ No newline at end of file +} diff --git a/koin/src/main/java/in/koreatech/koin/di/network/NoAuthNetworkModule.kt b/data/src/main/java/in/koreatech/koin/data/di/network/NoAuthNetworkModule.kt similarity index 98% rename from koin/src/main/java/in/koreatech/koin/di/network/NoAuthNetworkModule.kt rename to data/src/main/java/in/koreatech/koin/data/di/network/NoAuthNetworkModule.kt index acfeae046..5458516ac 100644 --- a/koin/src/main/java/in/koreatech/koin/di/network/NoAuthNetworkModule.kt +++ b/data/src/main/java/in/koreatech/koin/data/di/network/NoAuthNetworkModule.kt @@ -1,4 +1,4 @@ -package `in`.koreatech.koin.di.network +package `in`.koreatech.koin.data.di.network import `in`.koreatech.koin.core.qualifier.Auth import `in`.koreatech.koin.core.qualifier.NoAuth diff --git a/koin/src/main/java/in/koreatech/koin/di/repository/RepositoryModule.kt b/data/src/main/java/in/koreatech/koin/data/di/repository/RepositoryModule.kt similarity index 98% rename from koin/src/main/java/in/koreatech/koin/di/repository/RepositoryModule.kt rename to data/src/main/java/in/koreatech/koin/data/di/repository/RepositoryModule.kt index c5f08e5ad..7081cae2a 100644 --- a/koin/src/main/java/in/koreatech/koin/di/repository/RepositoryModule.kt +++ b/data/src/main/java/in/koreatech/koin/data/di/repository/RepositoryModule.kt @@ -1,4 +1,4 @@ -package `in`.koreatech.koin.di.repository +package `in`.koreatech.koin.data.di.repository import `in`.koreatech.koin.data.repository.* import `in`.koreatech.koin.domain.repository.* @@ -129,7 +129,7 @@ object RepositoryModule { ): StoreRepository { return StoreRepositoryImpl(storeRemoteDataSource) } - + @Provides @Singleton fun provideLandRepository( diff --git a/koin/src/main/java/in/koreatech/koin/di/source/LocalDataSourceModule.kt b/data/src/main/java/in/koreatech/koin/data/di/source/LocalDataSourceModule.kt similarity index 80% rename from koin/src/main/java/in/koreatech/koin/di/source/LocalDataSourceModule.kt rename to data/src/main/java/in/koreatech/koin/data/di/source/LocalDataSourceModule.kt index 6667e7860..a99b061dc 100644 --- a/koin/src/main/java/in/koreatech/koin/di/source/LocalDataSourceModule.kt +++ b/data/src/main/java/in/koreatech/koin/data/di/source/LocalDataSourceModule.kt @@ -1,6 +1,5 @@ -package `in`.koreatech.koin.di.source +package `in`.koreatech.koin.data.di.source -import `in`.koreatech.koin.data.source.local.* import android.content.Context import dagger.Module import dagger.Provides @@ -8,6 +7,11 @@ import dagger.hilt.InstallIn import dagger.hilt.android.qualifiers.ApplicationContext import dagger.hilt.components.SingletonComponent import `in`.koreatech.koin.core.qualifier.IoDispatcher +import `in`.koreatech.koin.data.source.local.BusLocalDataSource +import `in`.koreatech.koin.data.source.local.DeptLocalDataSource +import `in`.koreatech.koin.data.source.local.SignupTermsLocalDataSource +import `in`.koreatech.koin.data.source.local.TokenLocalDataSource +import `in`.koreatech.koin.data.source.local.VersionLocalDataSource import kotlinx.coroutines.CoroutineDispatcher import javax.inject.Singleton diff --git a/koin/src/main/java/in/koreatech/koin/di/source/RemoteDataSourceModule.kt b/data/src/main/java/in/koreatech/koin/data/di/source/RemoteDataSourceModule.kt similarity index 98% rename from koin/src/main/java/in/koreatech/koin/di/source/RemoteDataSourceModule.kt rename to data/src/main/java/in/koreatech/koin/data/di/source/RemoteDataSourceModule.kt index 59d1448c5..b1da05a1f 100644 --- a/koin/src/main/java/in/koreatech/koin/di/source/RemoteDataSourceModule.kt +++ b/data/src/main/java/in/koreatech/koin/data/di/source/RemoteDataSourceModule.kt @@ -1,4 +1,4 @@ -package `in`.koreatech.koin.di.source +package `in`.koreatech.koin.data.di.source import `in`.koreatech.koin.data.api.* import `in`.koreatech.koin.data.api.auth.UserAuthApi @@ -76,7 +76,7 @@ object RemoteDataSourceModule { ): StoreRemoteDataSource { return StoreRemoteDataSource(storeApi) } - + @Provides @Singleton fun provideLandRemoteDataSource( diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index ef87250ae..43221ec78 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -47,6 +47,7 @@ butterknifeVersion = "10.1.0" googleServiceVersion = "4.3.14" composeNavigationVersion = "2.7.7" orbitVersion="7.0.1" +hiltComposeVersion="1.0.0" [libraries] androidx-activity-ktx = { module = "androidx.activity:activity-ktx", version.ref = "activityKtxVersion" } @@ -121,6 +122,8 @@ orbit-core = {module= "org.orbit-mvi:orbit-core", version.ref = "orbitVersion"} orbit-viewmodel = {module= "org.orbit-mvi:orbit-viewmodel", version.ref = "orbitVersion"} orbit-compose = {module= "org.orbit-mvi:orbit-compose", version.ref = "orbitVersion"} +hilt-compose= {module= "androidx.hilt:hilt-navigation-compose", version.ref = "hiltComposeVersion"} + [plugins] android-application = { id = "com.android.application", version.ref = "androidGradleVersion" } kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlinVersion" } diff --git a/koin/build.gradle b/koin/build.gradle index a94a729ed..dbb4f7084 100644 --- a/koin/build.gradle +++ b/koin/build.gradle @@ -6,6 +6,7 @@ plugins { id 'com.google.firebase.crashlytics' id 'com.google.firebase.appdistribution' id 'com.google.dagger.hilt.android' + id 'org.jetbrains.kotlin.android' } def applicationName = 'koin'