Last active
December 28, 2022 12:01
-
-
Save maxirosson/5b0ffb3d9466787a9f0343df8ad834e5 to your computer and use it in GitHub Desktop.
Versioning Android Apps - Simple schema - https://medium.com/dipien/versioning-android-apps-d6ec171cfd82
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
apply plugin: 'com.android.application' | |
ext.versionMajor = 1 | |
ext.versionMinor = 2 | |
ext.versionPatch = 3 | |
ext.versionClassifier = null | |
ext.isSnapshot = true | |
android { | |
defaultConfig { | |
versionCode generateVersionCode() // 010203 | |
versionName generateVersionName() // 1.2.3-SNAPSHOT | |
} | |
} | |
private Integer generateVersionCode() { | |
return ext.versionMajor * 10000 + ext.versionMinor * 100 + ext.versionPatch | |
} | |
private String generateVersionName() { | |
String versionName = "${ext.versionMajor}.${ext.versionMinor}.${ext.versionPatch}" | |
if (ext.versionClassifier == null && ext.isSnapshot) { | |
ext.versionClassifier = "SNAPSHOT" | |
} | |
if (ext.versionClassifier != null) { | |
versionName += "-" + ext.versionClassifier | |
} | |
return versionName; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment