Posted By


bilo on 03/22/14

Tagged


Statistics


Viewed 190 times
Favorited by 0 user(s)

increaseVersionCode


/ Published in: Groovy
Save to your folder(s)



Copy this code and paste it in your HTML
  1. task('increaseVersionCode') << {
  2. def manifestFile = file("AndroidManifest.xml")
  3. def pattern = Pattern.compile("versionCode=\"(\\d+)\"")
  4. def manifestText = manifestFile.getText()
  5. def matcher = pattern.matcher(manifestText)
  6. matcher.find()
  7. def versionCode = Integer.parseInt(matcher.group(1))
  8. def manifestContent = matcher.replaceAll("versionCode=\"" + ++versionCode + "\"")
  9. manifestFile.write(manifestContent)
  10. }
  11.  
  12. tasks.whenTaskAdded { task ->
  13. if (task.name == 'generateReleaseBuildConfig') {
  14. task.dependsOn 'increaseVersionCode'
  15. }
  16. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.