Skip to content

Instantly share code, notes, and snippets.

@segunfamisa
Last active June 22, 2020 11:43
Show Gist options
  • Save segunfamisa/b659ebdb04735475b48a7935d646fd03 to your computer and use it in GitHub Desktop.
Save segunfamisa/b659ebdb04735475b48a7935d646fd03 to your computer and use it in GitHub Desktop.
Using gradle extra properties to manage Android dependency versioning
// app module build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion rootProject.compileSdkVersion
buildToolsVersion rootProject.buildToolsVersion
defaultConfig {
applicationId "com.segunfamisa.gradleextraproperties"
minSdkVersion rootProject.minSdkVersion
targetSdkVersion rootProject.targetSdkVersion
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile "com.android.support:appcompat-v7:$rootProject.supportLibraryVersion"
compile "com.android.support:design:$rootProject.supportLibraryVersion"
compile "com.android.support:percent:$rootProject.supportLibraryVersion"
compile "com.android.support:cardview-v7:$rootProject.supportLibraryVersion"
compile "com.android.support:gridlayout-v7:$rootProject.supportLibraryVersion"
//play services
compile "com.google.android.gms:play-services-location:$rootProject.playServicesVersion"
compile "com.google.android.gms:play-services-gcm:$rootProject.playServicesVersion"
testCompile "junit:junit:$rootProject.jUnitVersion"
}
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.0-alpha4'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
ext {
// sdk and tools
minSdkVersion = 14
targetSdkVersion = 23
compileSdkVersion = 23
buildToolsVersion = '23.0.2'
supportLibraryVersion = '23.4.0'
playServicesVersion = '9.0.0'
jUnitVersion = '4.12'
}
@juancoob
Copy link

Thank you :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment