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
task('increaseVersionCode') << { | |
def manifestFile = file("src/main/AndroidManifest.xml") | |
def pattern = Pattern.compile("versionCode=\"(\\d+)\"") | |
def manifestText = manifestFile.getText() | |
def matcher = pattern.matcher(manifestText) | |
matcher.find() | |
def versionCode = Integer.parseInt(matcher.group(1)) | |
android.defaultConfig.versionCode = versionCode + 1 | |
println "Setting version code to ${android.defaultConfig.versionCode}" | |
def manifestContent = matcher.replaceAll("versionCode=\"" + android.defaultConfig.versionCode + "\"") |