Skip to content

Instantly share code, notes, and snippets.

@JLamkin
Forked from mente/build.gradle
Last active December 31, 2015 15:59
Show Gist options
  • Save JLamkin/8011068 to your computer and use it in GitHub Desktop.
Save JLamkin/8011068 to your computer and use it in GitHub Desktop.
Changed each to all, since each is out of date. And added more generic replacement.
android {
defaultConfig {
versionName "actionbar"
}
signingConfigs {
release {
storeFile file("android.keystore")
...
}
}
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}
}
buildTypes {
debug {
versionNameSuffix "dev"
}
release {
signingConfig signingConfigs.release
}
}
buildToolsVersion "17.0"
compileSdkVersion 17
}
project.archivesBaseName = "Acme-Project-REPLACEME";
android.applicationVariants.all { variant ->
def apk = variant.outputFile
def newManifest = variant.processManifest.manifestOutputFile
def versionCode = getVersionCode(newManifest.path)
if (versionCode == -1) {
return
}
def newName
if (variant.buildType.name == "release") {
newName = apk.name.replace("REPLACEME", versionCode);
} else {
newName = apk.name.replace("REPLACEME", "");
}
//noinspection GroovyAssignabilityCheck
variant.outputFile = new File(apk.parentFile, newName)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment