Posted By

bilo on 03/22/14


Tagged


Versions (?)

increaseVersionCode


 / Published in: Groovy
 

  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  

You need to login to post a comment.