Skip to content

Instantly share code, notes, and snippets.

@lecho
Created February 18, 2014 19:35
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 lecho/9078264 to your computer and use it in GitHub Desktop.
Save lecho/9078264 to your computer and use it in GitHub Desktop.
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.7.0'
}
}
apply plugin: 'android'
android {
compileSdkVersion 19
buildToolsVersion "19.0.1"
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}
}
signingConfigs {
myConfig {
storeFile file("debug.keystore")
storePassword "android"
keyAlias "androiddebugkey"
keyPassword "android"
}
}
buildTypes {
release {
signingConfig signingConfigs.myConfig
}
}
}
import com.android.builder.DefaultManifestParser
def getVersion(manifestFile){
def manifestParser = new DefaultManifestParser();
return manifestParser.getVersionName(manifestFile);
}
android.applicationVariants.all { variant ->
println "${variant.name} output ${variant.outputFile.name}";
def manifestFile = file(android.sourceSets.main.manifest.srcFile);
def versionName = getVersion(manifestFile);
def apk = variant.outputFile;
if (variant.zipAlign) {
def newName = apk.name.replace(".apk", "-${versionName}.apk");
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