Skip to content

Instantly share code, notes, and snippets.

@IlyaEremin
Created February 18, 2017 20:34
Embed
What would you like to do?
Example of managing dependencies in separate file
apply from: 'deps.gradle'
// ...
dependencies {
compile supportLibs
compile rxJavaLibs
compile retrofitLibs
compile okHttpLibs
compile 'com.jakewharton:butterknife:7.0.0' // view injection
compile 'com.github.bumptech.glide:glide:3.7.0'
compile 'com.f2prateek.dart:dart:1.1.0' // activity arguments arguments inject
testCompile unitTestLibs
androidTestCompile androidTestsLibs
}
ext {
versions = [
okHttp : '3.3.1',
support : '25.1.0',
retrofit : '2.0.2',
espressoVersion : '2.2.2',
BUILD_TOOLS_VERSION: '25.0.1',
MIN_SDK_VERSION : 14,
TARGET_SDK_VERSION : 25
]
supportDeps = [
appcompatV7 : "com.android.support:appcompat-v7:$versions.support",
recyclerView : "com.android.support:recyclerview-v7:$versions.support",
supportAnnotation: "com.android.support:support-annotations:$versions.support",
design : "com.android.support:design:$versions.support",
gridLayout : "com.android.support:gridlayout-v7:$versions.support"
cardView : "com.android.support:cardview-v7:$versions.support"
palette : "com.android.support:palette-v7:$versions.support"
]
rxJava = [
rxJava : 'io.reactivex:rxjava:1.1.6',
rxAndroid: 'io.reactivex:rxandroid:1.2.1'
]
retrofit = [
retrofit : "com.squareup.retrofit2:retrofit:$versions.retrofit",
rxAdapter : "com.squareup.retrofit2:adapter-rxjava:$versions.retrofit",
gsonConverter: "com.squareup.retrofit2:converter-gson:$versions.retrofit"
]
okHttp = [
logger: "com.squareup.okhttp3:logging-interceptor:$versions.okHttp",
self : "com.squareup.okhttp3:okhttp:$versions.okHttp"
]
unitTests = [
supportAnnotation: "com.android.support:support-annotations:$versions.support",
junit : 'junit:junit:4.12',
robolectric : 'org.robolectric:robolectric:3.0',
assertj : 'com.squareup.assertj:assertj-android:1.0.0'
]
androidTests = [
espressoCore : "com.android.support.test.espresso:espresso-core:$versions.espressoVersion",
espressoContrib: "com.android.support.test.espresso:espresso-contrib:$versions.espressoVersion",
espressoIntents: "com.android.support.test.espresso:espresso-intents:$versions.espressoVersion",
testRunner : "com.android.support.test:runner:0.5",
testRules : "com.android.support.test:rules:0.5"
]
supportLibs = supportDeps.values()
retrofitLibs = retrofit.values()
okHttpLibs = okHttp.values()
rxJavaLibs = rxJava.values()
unitTestLibs = unitTests.values()
androidTestsLibs = androidTests.values() + supportLibs
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment