Created
December 10, 2013 19:20
-
-
Save felipecsl/7896478 to your computer and use it in GitHub Desktop.
Increments the android versionCode automatically on each debug or release build
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
task('increaseVersionCode') << { | |
def manifestFile = file("src/main/AndroidManifest.xml") | |
def pattern = Pattern.compile("versionCode=\"(\\d+)\"") | |
def matcher = pattern.matcher((CharSequence)manifestFile.getText()) | |
matcher.find() | |
def versionCode = Integer.parseInt(matcher.group(1)) | |
manifestFile.write(matcher.replaceAll("versionCode=\"" + ++versionCode + "\"")) | |
} | |
assembleDebug.dependsOn 'increaseVersionCode' | |
assembleRelease.dependsOn 'increaseVersionCode' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment