Last active
December 6, 2017 10:25
-
-
Save nhancv/3528168aea5924143acd1a31c1e5963b to your computer and use it in GitHub Desktop.
React native: Gradle android version strategy (android/app/build.gradle)
This file contains 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
import groovy.json.JsonSlurper | |
def getNpmVersion() { | |
def inputFile = new File("../package.json") | |
def packageJson = new JsonSlurper().parseText(inputFile.text) | |
return packageJson["version"] | |
} | |
def getCommitTime() { | |
return (Integer) (Long.valueOf('git log -1 --pretty=format:%ct'.execute().getText().trim())/3600) | |
} | |
ext { | |
_VERSION_NAME = getNpmVersion() | |
_VERSION_CODE = System.getenv("BUILD_NUMBER") as Integer ?: getCommitTime() | |
} | |
afterEvaluate { | |
println '****************************************' | |
println 'Version Name: ' + _VERSION_NAME | |
println 'Version Code: ' + _VERSION_CODE | |
println '****************************************' | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment