Skip to content

Instantly share code, notes, and snippets.

@Wottrich
Created February 28, 2020 20:11
Show Gist options
  • Save Wottrich/5762ef812fc24d6a16f30dc339310b45 to your computer and use it in GitHub Desktop.
Save Wottrich/5762ef812fc24d6a16f30dc339310b45 to your computer and use it in GitHub Desktop.
[Android] Organize your gradle dependencies
ext {
defaultLinks = [
kotlin : "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version",
appCompat : 'androidx.appcompat:appcompat:1.0.2',
core : 'androidx.core:core-ktx:1.0.2',
constraintLayout : 'androidx.constraintlayout:constraintlayout:1.1.3'
]
testLinks = [
junit : 'junit:junit:4.12',
junitExt : 'androidx.test.ext:junit:1.1.1',
espresso : 'androidx.test.espresso:espresso-core:3.2.0',
mockito : 'org.mockito:mockito-core:1.10.19',
mockitoInline : 'org.mockito:mockito-inline:2.8.47',
mockitoKotlin : 'com.nhaarman.mockitokotlin2:mockito-kotlin:2.2.0'
]
retrofitLinks = [
retrofit : 'com.squareup.retrofit2:retrofit:2.6.2',
gson : 'com.google.code.gson:gson:2.8.5',
retrofitConverter : 'com.squareup.retrofit2:converter-gson:2.5.0',
okHttp : 'com.squareup.okhttp:okhttp:2.6.0',
okHttpConverter : 'com.squareup.okhttp3:logging-interceptor:3.12.1'
]
}
static def automaticImplementation (LinkedHashMap links, Closure closure) {
links.each { key ->
closure(key.value)
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
automaticImplementation (defaultLinks) {
implementation it
}
automaticImplementation (retrofitLinks) {
implementation it
}
automaticImplementation (testLinks) {
implementation it
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment