Skip to content

Instantly share code, notes, and snippets.

@dominicthomas
Created February 25, 2015 14:28
Show Gist options
  • Save dominicthomas/6676e81b2d6d1a30ea8f to your computer and use it in GitHub Desktop.
Save dominicthomas/6676e81b2d6d1a30ea8f to your computer and use it in GitHub Desktop.
import com.android.build.OutputFile;
ext {
buildToolsVersion = System.env.CUSTOM_BUILDTOOLS != null ? System.env.CUSTOM_BUILDTOOLS : '20.0.0'
}
buildscript {
def gradleVersion = System.env.CUSTOM_GRADLE != null ? System.env.CUSTOM_GRADLE : '0.14.0'
repositories {
if (System.env.CUSTOM_REPO != null) {
maven { url System.env.CUSTOM_REPO }
} else {
mavenCentral()
}
}
dependencies {
classpath "com.android.tools.build:gradle:$gradleVersion"
}
}
apply plugin: 'com.android.application'
android {
compileSdkVersion 19
buildToolsVersion = rootProject.ext.buildToolsVersion
defaultConfig {
versionCode 12
minSdkVersion 16
targetSdkVersion 20
buildConfigField "String", "FOO", "\"bar\""
}
splits {
density {
enable true
exclude "ldpi", "tvdpi", "xxxhdpi", "400dpi", "560dpi"
compatibleScreens 'small', 'normal', 'large', 'xlarge'
}
}
}
// map for the version code
ext.versionCodes = [all:1, mdpi:2, hdpi:3, xhdpi:4, xxhdpi:5]
android.applicationVariants.all { variant ->
// assign different version code for each output
variant.outputs.each { output ->
def key = output.getFilter(OutputFile.DENSITY) == null ? "all" : output.getFilter(OutputFile.DENSITY)
output.versionCodeOverride = project.ext.versionCodes.get(key) * 100 + android.defaultConfig.versionCode
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment