-
-
Save nsmirosh/5ec7aa47289063023cd0af06fdee0c47 to your computer and use it in GitHub Desktop.
Auto-increment build version
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
| android { | |
| val versionPropsFile = file("../version.properties") | |
| if (versionPropsFile.canRead()) { | |
| val versionProps = Properties() | |
| versionProps.load(FileInputStream(versionPropsFile)) | |
| val code = versionProps["VERSION_CODE"].toString().toInt() + 1 | |
| versionProps["VERSION_CODE"] = code.toString() | |
| versionProps.store(versionPropsFile.writer(), null) | |
| defaultConfig { | |
| versionCode = code | |
| } | |
| } else { | |
| throw GradleException("Could not read version.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
| VERSION_CODE=0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment