Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save beshkenadze/7868467 to your computer and use it in GitHub Desktop.
Save beshkenadze/7868467 to your computer and use it in GitHub Desktop.
// add method to get the versionCode from cli param
// eg. `gradle tasks -PversionCode=999`
/**
* Get the version code from command line param
*
* @return int If the param -PversionCode is present then return int value or -1
*/
def getVersionCode = { ->
def code = project.hasProperty('versionCode') ? versionCode.toInteger() : -1
println "VersionCode is set to $code"
return code
}
// add to defaultConfig
android {
defaultConfig {
versionCode getVersionCode()
//...
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment