Миграция на Kotlin DSL

This commit is contained in:
2023-04-07 21:34:59 +03:00
parent 8db9a89237
commit 481cd770f4
13 changed files with 203 additions and 108 deletions
+76
View File
@@ -0,0 +1,76 @@
import org.gradle.api.artifacts.dsl.DependencyHandler
object AppDependencies {
//std lib
val kotlinStdLib = "org.jetbrains.kotlin:kotlin-stdlib-jdk7:${Versions.kotlin}"
//android ui
private val appcompat = "androidx.appcompat:appcompat:${Versions.appcompat}"
private val coreKtx = "androidx.core:core-ktx:${Versions.coreKtx}"
private val constraintLayout =
"androidx.constraintlayout:constraintlayout:${Versions.constraintLayout}"
private val pieChartLib = "com.github.PhilJay:MPAndroidChart:v3.1.0"
//test libs
private val junit = "junit:junit:${Versions.junit}"
private val extJUnit = "androidx.test.ext:junit:${Versions.extJunit}"
private val espressoCore = "androidx.test.espresso:espresso-core:${Versions.espresso}"
val appLibraries = arrayListOf<String>().apply {
add(kotlinStdLib)
add(coreKtx)
add(appcompat)
add(constraintLayout)
add(pieChartLib)
}
val androidTestLibraries = arrayListOf<String>().apply {
add(extJUnit)
add(espressoCore)
}
val testLibraries = arrayListOf<String>().apply {
add(junit)
}
}
//util functions for adding the different type dependencies from build.gradle file
fun DependencyHandler.kapt(list: List<String>) {
list.forEach { dependency ->
add("kapt", dependency)
}
}
fun DependencyHandler.implementation(list: List<String>) {
list.forEach { dependency ->
add("implementation", dependency)
}
}
fun DependencyHandler.testImplementation(list: List<String>){
list.forEach { dependency ->
add("testImplementation", dependency)
}
}
fun DependencyHandler.androidTestImplementation(list: List<String>){
list.forEach { dependency ->
add("androidTestImplementation", dependency)
}
}
fun DependencyHandler.coreLibraryDesugaring(list: List<String>){
list.forEach { dependency ->
add("coreLibraryDesugaring", dependency)
}
}
fun DependencyHandler.debugImplementation(list: List<String>){
list.forEach { dependency ->
add("debugImplementation", dependency)
}
}