From a0b261d29ad0afecbfd04f3cdd51c49e0508c824 Mon Sep 17 00:00:00 2001 From: plamen5kov Date: Sun, 24 Jan 2016 14:48:48 +0200 Subject: [PATCH] enabled versioning from environment variable --- widgets/build.gradle | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/widgets/build.gradle b/widgets/build.gradle index 2998ee801..2d9af64b0 100644 --- a/widgets/build.gradle +++ b/widgets/build.gradle @@ -1,3 +1,7 @@ +import groovy.json.JsonSlurper //used to parse package.json +import groovy.json.JsonBuilder +import groovy.json.JsonOutput + def isWinOs = System.properties['os.name'].toLowerCase().contains('windows') apply plugin: 'com.android.library' @@ -57,6 +61,16 @@ task cleanDistDir (type: Delete) { delete "../dist/" } +task fixVersion << { + if(project.hasProperty("PACKAGE_VERSION")) { + def inputFile = new File("./package.json") + def json = new JsonSlurper().parseText(inputFile.text) + json.version = json.version + "-" + PACKAGE_VERSION + def jb = new JsonBuilder(json); + inputFile.text = JsonOutput.prettyPrint(jb.toString()) + } +} + task copyAar << { copy { from "../package.json" @@ -68,6 +82,15 @@ task copyAar << { } } +task revertPackageJson (type: Exec) { + if(isWinOs) { + commandLine "cmd", "/c", "git", "checkout", "--", "../package.json" + } + else { + commandLine "git", "checkout", "--", "../package.json" + } +} + task packFramework (type: Exec) { workingDir "../dist" @@ -79,6 +102,9 @@ task packFramework (type: Exec) { } } + assembleRelease.dependsOn(cleanDistDir) -copyAar.dependsOn(assembleRelease) -packFramework.dependsOn(copyAar) +fixVersion.dependsOn(assembleRelease) +copyAar.dependsOn(fixVersion) +revertPackageJson.dependsOn(copyAar) +packFramework.dependsOn(revertPackageJson)