Last active
July 15, 2017 10:28
-
-
Save jensgreiner/97c0d84d3e19cfbe4d54c2451d80cecd to your computer and use it in GitHub Desktop.
Add auto incremented versionCode using a properties file
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
/** | |
* Adds auto incremented versionCode number | |
* Found on stackoverflow | |
* see https://stackoverflow.com/a/25166200/1469260 | |
*/ | |
def Properties versionProps = new Properties() | |
def versionPropsFile = file('version.properties') | |
if (versionPropsFile.exists()) | |
versionProps.load(new FileInputStream(versionPropsFile)) | |
def code = (versionProps['VERSION_CODE'] ?: "0").toInteger() + 1 | |
versionProps['VERSION_CODE'] = code.toString() | |
versionProps.store(versionPropsFile.newWriter(), null) | |
defaultConfig { | |
applicationId "com.example.android.miwok" | |
minSdkVersion 15 | |
//noinspection OldTargetApi | |
targetSdkVersion 25 | |
versionCode code | |
versionName "1.2." + code | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment