Skip to content

Commit

Permalink
add hilt for project [FoKE-Developers#1]
Browse files Browse the repository at this point in the history
  • Loading branch information
DokySp committed Sep 22, 2024
1 parent 97d163c commit ba63d6e
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 9 deletions.
5 changes: 0 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,3 @@
## Dependencies
- 프로젝트 및 관련 버전은 libs.versions.toml 에서 관리
- 기타 의존성은 사용한 모듈에서 관리

## TODO
- 기본적인 모듈 + Manifest 설정 추가 후 커밋
- 모듈간 의존성 추가 커밋
- 샘플코드 + Hilt 추가 후 커밋
2 changes: 2 additions & 0 deletions app/src/main/java/com/foke/together/MainApplication.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ package com.foke.together

import android.app.Application
import com.foke.together.util.AppLog
import dagger.hilt.android.HiltAndroidApp

@HiltAndroidApp
class MainApplication: Application() {
override fun onCreate() {
super.onCreate()
Expand Down
22 changes: 22 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ plugins {
alias(libs.plugins.android.application) apply false
alias(libs.plugins.jetbrains.kotlin.android) apply false
alias(libs.plugins.android.library) apply false

alias(libs.plugins.hilt) apply false
alias(libs.plugins.kotlin.kapt) apply false
}

subprojects {
Expand Down Expand Up @@ -78,4 +81,23 @@ subprojects {
}
}
}

plugins.withId("org.jetbrains.kotlin.android") {
apply(plugin = "kotlin-kapt")
apply(plugin = "dagger.hilt.android.plugin")

dependencies {
add("implementation", libs.hilt)
add("kapt", libs.hilt.compiler)
}

configure<org.jetbrains.kotlin.gradle.plugin.KaptExtension> {
correctErrorTypes = true
}
}

configurations.all {
// resolve error of import duplicated "annotations" with "org.jetbrains.annotations
exclude(group = "com.intellij", module = "annotations")
}
}
35 changes: 31 additions & 4 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ agp = "8.5.2"
kotlin = "1.9.20"
coreKtx = "1.13.1"

# kapt -----------
kotlin-kapt = "1.9.20"

# android --------
appcompat = "1.7.0"
composeCompiler = "1.5.5"
Expand All @@ -24,6 +27,16 @@ activityCompose = "1.9.2"
composeBom = "2024.09.02"
material = "1.12.0"

# data -----------
room = "2.6.1"
androidx-datastore = "1.1.1"
protobuf = "3.23.2"

# hilt -----------
hilt = "2.49"
androidx-hilt-compiler = "1.2.0"
androidx-hilt-navigation-compose = "1.2.0"

# test -----------
junit = "4.13.2"
junitVersion = "1.2.1"
Expand All @@ -32,11 +45,10 @@ espressoCore = "3.6.1"


[libraries]
# core -----------
androidx-core-ktx = { group = "androidx.core", name = "core-ktx", version.ref = "coreKtx" }
junit = { group = "junit", name = "junit", version.ref = "junit" }
androidx-junit = { group = "androidx.test.ext", name = "junit", version.ref = "junitVersion" }
androidx-espresso-core = { group = "androidx.test.espresso", name = "espresso-core", version.ref = "espressoCore" }
androidx-appcompat = { group = "androidx.appcompat", name = "appcompat", version.ref = "appcompat" }

# android --------
material = { group = "com.google.android.material", name = "material", version.ref = "material" }
androidx-lifecycle-runtime-ktx = { group = "androidx.lifecycle", name = "lifecycle-runtime-ktx", version.ref = "lifecycleRuntimeKtx" }
androidx-activity-compose = { group = "androidx.activity", name = "activity-compose", version.ref = "activityCompose" }
Expand All @@ -49,10 +61,25 @@ androidx-ui-test-manifest = { group = "androidx.compose.ui", name = "ui-test-man
androidx-ui-test-junit4 = { group = "androidx.compose.ui", name = "ui-test-junit4" }
androidx-material3 = { group = "androidx.compose.material3", name = "material3" }

# test -----------
junit = { group = "junit", name = "junit", version.ref = "junit" }
androidx-junit = { group = "androidx.test.ext", name = "junit", version.ref = "junitVersion" }
androidx-espresso-core = { group = "androidx.test.espresso", name = "espresso-core", version.ref = "espressoCore" }
androidx-appcompat = { group = "androidx.appcompat", name = "appcompat", version.ref = "appcompat" }

# hilt -----------
hilt = { group = "com.google.dagger", name = "hilt-android", version.ref = "hilt" }
hilt-compiler = { group = "com.google.dagger", name = "hilt-android-compiler", version.ref = "hilt" }
androidx-hilt-compiler = { group = "androidx.hilt", name = "hilt-compiler", version.ref = "androidx-hilt-compiler" }
androidx-hilt-navigation-compose = { group = "androidx.hilt", name = "hilt-navigation-compose", version.ref = "androidx-hilt-navigation-compose" }



[plugins]
android-application = { id = "com.android.application", version.ref = "agp" }
jetbrains-kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
android-library = { id = "com.android.library", version.ref = "agp" }
kotlin-kapt = { id = "org.jetbrains.kotlin.kapt", version.ref = "kotlin-kapt"}

# hilt -----------
hilt = { id = "com.google.dagger.hilt.android", version.ref = "hilt"}
3 changes: 3 additions & 0 deletions presenter/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ dependencies {
implementation(libs.androidx.ui.graphics)
implementation(libs.androidx.ui.tooling.preview)
implementation(libs.androidx.material3)
implementation(libs.androidx.hilt.compiler)
implementation(libs.androidx.hilt.navigation.compose)

testImplementation(libs.junit)
androidTestImplementation(libs.androidx.junit)
androidTestImplementation(libs.androidx.espresso.core)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.tooling.preview.Preview
import com.foke.together.presenter.ui.theme.FourCutTogetherTheme
import dagger.hilt.android.AndroidEntryPoint

@AndroidEntryPoint
class MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
Expand Down

0 comments on commit ba63d6e

Please sign in to comment.