Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@alexfu
Created November 30, 2017 16:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alexfu/688df5ab34d1f27580064729e33bf60b to your computer and use it in GitHub Desktop.
Save alexfu/688df5ab34d1f27580064729e33bf60b to your computer and use it in GitHub Desktop.
Grouping shared dependencies
/**
* This file would be located under /path/to/project/app/build.gradle
*/
apply plugin: 'com.android.application'
android {
// Usual stuff
}
apply from: "$project.rootDir/shared_dependencies.gradle"
dependencies {
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
sharedDependencies.network()
}
/**
* This file would be located under /path/to/project/mylib/build.gradle
*/
apply plugin: 'com.android.library'
android {
// Usual stuff
}
apply from: "$project.rootDir/shared_dependencies.gradle"
dependencies {
implementation 'com.android.support:appcompat-v7:26.1.0'
sharedDependencies.network()
}
/**
* This file would be located under /path/to/project/shared_dependencies.gradle
*/
def dependencyGroup(Closure closure) {
closure.delegate = dependencies
return closure
}
ext.sharedDependencies = [
network: dependencyGroup {
implementation "com.squareup.retrofit2:retrofit:2.3.0"
}
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment