-
-
Save morristech/dbcbe0c087af04086549d252513d31f4 to your computer and use it in GitHub Desktop.
Gradle automated build number incrementing
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
| def versionFile = file('version.properties') | |
| ext.buildnum = new Properties([BUILD_NUMBER: "0"]); | |
| if (versionFile.isFile()) { | |
| versionFile.withReader { buildnum.load(it) } | |
| } | |
| def buildNumber = Integer.toString(Integer.parseInt(buildnum.BUILD_NUMBER) + 1) | |
| buildnum.BUILD_NUMBER = buildNumber | |
| task('saveBuildNumber') << { | |
| versionFile.withWriter { buildnum.store(it, "Automated build number increase") } | |
| } | |
| tasks.whenTaskAdded { task -> | |
| if (task.name == 'build') { | |
| task.dependsOn 'saveBuildNumber' | |
| } | |
| } |
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
| #Automated build number increase | |
| #Thu Jul 05 19:21:05 CDT 2018 | |
| BUILD_NUMBER=1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment