Android buildSrc 의존성 관리하기 with Kotlin DSL | Dependency 관리

buildSrc 디렉토리 만들기

preview

build.gradle.kts 파일 추가

buildSrc 우클릭하고 File 생성하여 build.gradle.kts 파일을 만들고 아래의 내용르 복사붙여넣기 해주세요.

plugins {
    `kotlin-dsl` // enable the Kotlin-DSL
}

repositories {
    google()
    mavenCentral()
}

src/main/kotlin or src/main/java 추가

preview

Versions.kt 파일생성

object AndroidX {

    const val CORE_KTX = "androidx.core:core-ktx:1.9.0"
    const val APPCOMPAT = "androidx.appcompat:appcompat:1.5.1"
    const val CONSTRAINTLayout = "androidx.constraintlayout:constraintlayout:2.1.4"
    const val LIFECYCLE_LIVEDATA_KTX = "androidx.lifecycle:lifecycle-livedata-ktx:2.5.1"
    const val LIFECYCLE_VIEWMODEL_KTX = "androidx.lifecycle:lifecycle-viewmodel-ktx:2.5.1"
    const val NAVIGATION_FRAGMENT_KTX = "androidx.navigation:navigation-fragment-ktx:2.5.3"
    const val NAVIGATION_UI_KTX = "androidx.navigation:navigation-ui-ktx:2.5.3"
}

object Google {
    const val MATERIAL = "com.google.android.material:material:1.7.0"
}
dependencies {

    implementation(Google.MATERIAL)

    implementation(AndroidX.CORE_KTX)
    implementation(AndroidX.APPCOMPAT)
    implementation(AndroidX.CONSTRAINTLayout)
    implementation(AndroidX.LIFECYCLE_LIVEDATA_KTX)
    implementation(AndroidX.LIFECYCLE_VIEWMODEL_KTX)
    implementation(AndroidX.NAVIGATION_FRAGMENT_KTX)
    implementation(AndroidX.NAVIGATION_UI_KTX)
}

결론



Related Posts