Skip to content

Instantly share code, notes, and snippets.

@worstkiller
Created August 23, 2020 10:31
Show Gist options
  • Save worstkiller/95982e152df7d3465c6ec0ad7d58b170 to your computer and use it in GitHub Desktop.
Save worstkiller/95982e152df7d3465c6ec0ad7d58b170 to your computer and use it in GitHub Desktop.
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}"
//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)
}
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.androidTestImplementation(list: List<String>) {
list.forEach { dependency ->
add("androidTestImplementation", dependency)
}
}
fun DependencyHandler.testImplementation(list: List<String>) {
list.forEach { dependency ->
add("testImplementation", dependency)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment