Skip to content

Instantly share code, notes, and snippets.

@doc2dev
Last active January 22, 2019 11:56
Show Gist options
  • Save doc2dev/1ddac83d09fa98896d165bcdfaa417e3 to your computer and use it in GitHub Desktop.
Save doc2dev/1ddac83d09fa98896d165bcdfaa417e3 to your computer and use it in GitHub Desktop.
def versionPropsFile = file('version.properties')
if (versionPropsFile.canRead()) {
Properties versionProps = new Properties()
versionProps.load(new FileInputStream(versionPropsFile))
def code = versionProps['VERSION_CODE'].toInteger() + 1
def name = versionProps['VERSION_NAME']
versionProps['VERSION_CODE'] = code.toString()
versionProps.store(versionPropsFile.newWriter(), null)
defaultConfig {
applicationId "com.app.id"
minSdkVersion 16
targetSdkVersion 27
versionCode code
versionName name + " - " + code
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled true
vectorDrawables.useSupportLibrary = true
}
} else {
throw new GradleException("Could not read version.properties!")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment