Skip to content

Commit 4ae079e

Browse files
committed
add hilt for project [FoKE-Developers#1]
1 parent ce8e7d2 commit 4ae079e

File tree

6 files changed

+56
-5
lines changed

6 files changed

+56
-5
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# 같이네컷
2-
- Last updated: 2024-08-13
2+
- Last updated: 2024-09-22
33

44
## Specification
55

app/src/main/java/com/foke/together/MainApplication.kt

+2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@ package com.foke.together
22

33
import android.app.Application
44
import com.foke.together.util.AppLog
5+
import dagger.hilt.android.HiltAndroidApp
56

7+
@HiltAndroidApp
68
class MainApplication: Application() {
79
override fun onCreate() {
810
super.onCreate()

build.gradle.kts

+22
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ plugins {
33
alias(libs.plugins.android.application) apply false
44
alias(libs.plugins.jetbrains.kotlin.android) apply false
55
alias(libs.plugins.android.library) apply false
6+
7+
alias(libs.plugins.hilt) apply false
8+
alias(libs.plugins.kotlin.kapt) apply false
69
}
710

811
subprojects {
@@ -78,4 +81,23 @@ subprojects {
7881
}
7982
}
8083
}
84+
85+
plugins.withId("org.jetbrains.kotlin.android") {
86+
apply(plugin = "kotlin-kapt")
87+
apply(plugin = "dagger.hilt.android.plugin")
88+
89+
dependencies {
90+
add("implementation", libs.hilt)
91+
add("kapt", libs.hilt.compiler)
92+
}
93+
94+
configure<org.jetbrains.kotlin.gradle.plugin.KaptExtension> {
95+
correctErrorTypes = true
96+
}
97+
}
98+
99+
configurations.all {
100+
// resolve error of import duplicated "annotations" with "org.jetbrains.annotations
101+
exclude(group = "com.intellij", module = "annotations")
102+
}
81103
}

gradle/libs.versions.toml

+26-4
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ agp = "8.5.2"
1616
kotlin = "1.9.20"
1717
coreKtx = "1.13.1"
1818

19+
# kapt -----------
20+
kotlin-kapt = "1.9.20"
21+
1922
# android --------
2023
appcompat = "1.7.0"
2124
composeCompiler = "1.5.5"
@@ -24,6 +27,11 @@ activityCompose = "1.9.2"
2427
composeBom = "2024.09.02"
2528
material = "1.12.0"
2629

30+
# hilt -----------
31+
hilt = "2.49"
32+
androidx-hilt-compiler = "1.2.0"
33+
androidx-hilt-navigation-compose = "1.2.0"
34+
2735
# test -----------
2836
junit = "4.13.2"
2937
junitVersion = "1.2.1"
@@ -32,11 +40,10 @@ espressoCore = "3.6.1"
3240

3341

3442
[libraries]
43+
# core -----------
3544
androidx-core-ktx = { group = "androidx.core", name = "core-ktx", version.ref = "coreKtx" }
36-
junit = { group = "junit", name = "junit", version.ref = "junit" }
37-
androidx-junit = { group = "androidx.test.ext", name = "junit", version.ref = "junitVersion" }
38-
androidx-espresso-core = { group = "androidx.test.espresso", name = "espresso-core", version.ref = "espressoCore" }
39-
androidx-appcompat = { group = "androidx.appcompat", name = "appcompat", version.ref = "appcompat" }
45+
46+
# android --------
4047
material = { group = "com.google.android.material", name = "material", version.ref = "material" }
4148
androidx-lifecycle-runtime-ktx = { group = "androidx.lifecycle", name = "lifecycle-runtime-ktx", version.ref = "lifecycleRuntimeKtx" }
4249
androidx-activity-compose = { group = "androidx.activity", name = "activity-compose", version.ref = "activityCompose" }
@@ -49,10 +56,25 @@ androidx-ui-test-manifest = { group = "androidx.compose.ui", name = "ui-test-man
4956
androidx-ui-test-junit4 = { group = "androidx.compose.ui", name = "ui-test-junit4" }
5057
androidx-material3 = { group = "androidx.compose.material3", name = "material3" }
5158

59+
# test -----------
60+
junit = { group = "junit", name = "junit", version.ref = "junit" }
61+
androidx-junit = { group = "androidx.test.ext", name = "junit", version.ref = "junitVersion" }
62+
androidx-espresso-core = { group = "androidx.test.espresso", name = "espresso-core", version.ref = "espressoCore" }
63+
androidx-appcompat = { group = "androidx.appcompat", name = "appcompat", version.ref = "appcompat" }
64+
65+
# hilt -----------
66+
hilt = { group = "com.google.dagger", name = "hilt-android", version.ref = "hilt" }
67+
hilt-compiler = { group = "com.google.dagger", name = "hilt-android-compiler", version.ref = "hilt" }
68+
androidx-hilt-compiler = { group = "androidx.hilt", name = "hilt-compiler", version.ref = "androidx-hilt-compiler" }
69+
androidx-hilt-navigation-compose = { group = "androidx.hilt", name = "hilt-navigation-compose", version.ref = "androidx-hilt-navigation-compose" }
70+
5271

5372

5473
[plugins]
5574
android-application = { id = "com.android.application", version.ref = "agp" }
5675
jetbrains-kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
5776
android-library = { id = "com.android.library", version.ref = "agp" }
77+
kotlin-kapt = { id = "org.jetbrains.kotlin.kapt", version.ref = "kotlin-kapt"}
5878

79+
# hilt -----------
80+
hilt = { id = "com.google.dagger.hilt.android", version.ref = "hilt"}

presenter/build.gradle.kts

+3
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ dependencies {
3030
implementation(libs.androidx.ui.graphics)
3131
implementation(libs.androidx.ui.tooling.preview)
3232
implementation(libs.androidx.material3)
33+
implementation(libs.androidx.hilt.compiler)
34+
implementation(libs.androidx.hilt.navigation.compose)
35+
3336
testImplementation(libs.junit)
3437
androidTestImplementation(libs.androidx.junit)
3538
androidTestImplementation(libs.androidx.espresso.core)

presenter/src/main/java/com/foke/together/presenter/MainActivity.kt

+2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@ import androidx.compose.runtime.Composable
1212
import androidx.compose.ui.Modifier
1313
import androidx.compose.ui.tooling.preview.Preview
1414
import com.foke.together.presenter.ui.theme.FourCutTogetherTheme
15+
import dagger.hilt.android.AndroidEntryPoint
1516

17+
@AndroidEntryPoint
1618
class MainActivity : ComponentActivity() {
1719
override fun onCreate(savedInstanceState: Bundle?) {
1820
super.onCreate(savedInstanceState)

0 commit comments

Comments
 (0)