Created
October 20, 2014 20:25
-
-
Save sddamico/147bee247374b8bb7a33 to your computer and use it in GitHub Desktop.
Groovy increment versionCode in gradle.properties
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
// increment the versionCode in the build.properties file | |
def incrementBuildPropertiesVersion() { | |
// load build.properties file | |
def buildProps = new Properties() | |
def buildPropsFile = new File('android/build.properties') | |
buildProps.load(buildPropsFile.newDataInputStream()) | |
// get old version code from properties file | |
def oldVersionCode = buildProps.getProperty('VERSION_CODE') | |
def newVersionCode = Integer.parseInt(oldVersionCode) + 1 | |
println "Incrementing versionCode from ${oldVersionCode} to ${newVersionCode}" | |
buildProps.setProperty('VERSION_CODE', "${newVersionCode}") | |
// write properties file back to system | |
println "Writing build.properties" | |
buildProps.store(buildPropsFile.newWriter(), null) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment