Created
February 18, 2014 19:35
-
-
Save lecho/9078264 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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