Skip to content

Instantly share code, notes, and snippets.

@philgebhardt
Created May 29, 2018 17:13
Show Gist options
  • Save philgebhardt/7860708d05929d81ab58ca94e0a2ae06 to your computer and use it in GitHub Desktop.
Save philgebhardt/7860708d05929d81ab58ca94e0a2ae06 to your computer and use it in GitHub Desktop.
increment a project's gradle version
task increment {
doLast {
String patch=version.substring(version.lastIndexOf('.')+1)
int m=patch.toInteger()+1
String majorMinor=version.substring(0,version.lastIndexOf('.'))
String s=buildFile.getText().replaceFirst("version='${version}'","version='${majorMinor}.${m}'")
buildFile.setText(s)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment