我的build.gradle.kts包含我的依賴項,如下所示:
dependencies {
implementation("io.insert-koin:koin-core:3.1.6")
implementation("io.insert-koin:koin-test:3.1.6")
testImplementation(kotlin("test"))
}
如何將 移動3.1.6到區域變數(?),這樣我就可以避免在多個地方重復它。
uj5u.com熱心網友回復:
如果您只希望它是本地的,您可以為您的dependencies塊添加一個值:dependencies { val koinVersion = "3.1.6"
implementation("io.insert-koin:koin-core:$koinVersion")
implementation("io.insert-koin:koin-test:$koinVersion")
testImplementation(kotlin("test"))
}
如果要在多個位置使用它,可以在專案檔案中添加一個extra值:build.gradle.kts
val koinVersion by extra { "3.1.6" }
然后在應用程式的build.gradle.kts檔案中,在使用它之前將其匯入:
val koinVersion: String by rootProject.extra
dependencies {
implementation("io.insert-koin:koin-core:$koinVersion")
implementation("io.insert-koin:koin-test:$koinVersion")
testImplementation(kotlin("test"))
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/461044.html
