Skip to content

Commit

Permalink
Fix gradle filename script
Browse files Browse the repository at this point in the history
  • Loading branch information
corcoran committed Oct 25, 2016
1 parent 083d466 commit fe871da
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions Apphangar/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ android {
targetSdkVersion 22
versionCode 75
versionName "2.7"

project.ext.set("VERSION_NAME", defaultConfig.versionName)
}
lintOptions {
abortOnError true
Expand All @@ -43,21 +45,20 @@ android {
debug {
debuggable true
}

applicationVariants.all { variant ->
variant.outputs.each { variantEach ->
appendVersionNameVersionCode(variant, variantEach, defaultConfig, manifestParser)
variant.outputs.each { output ->

def newVersionName = project.VERSION_NAME

if (variant.buildType.name == android.buildTypes.debug.name) {
newVersionName += "-" + variant.buildType.name
}
output.outputFile = new File(output.outputFile.parent, "Hangar.apk".replace(".apk", "-" + newVersionName + ".apk"))
}
}
}
}

def appendVersionNameVersionCode(variant, variantEach, defaultConfig, manifestParser) {
def versionName = manifestParser.getVersionName(android.sourceSets.main.manifest.srcFile)
if(variant.buildType.name == android.buildTypes.debug.name) {
versionName += "-debug"
}
}
def file = variantEach.outputFile
variantEach.outputFile = new File(file.parent, "Hangar.apk".replace(".apk", "-" + versionName + ".apk"))
}

dependencies {
Expand Down

0 comments on commit fe871da

Please sign in to comment.