Modify build.gradle as part of task

I am trying to write release plugin that will take care of a couple of check, create and push a new git tag and finally modify the version of my java project to be major.minor.(build+1)-SNAPSHOT.

Most of it works, but I don’t really know how to go ahead and
a) set the new version on the build.gradle file itself
b) save that to disk
c) commit and push that file

Is that even possible? How do other people handle creating/releasing versions?


You could keep the version number in a separate file (e.g., version.txt) and update that. That’s probably easier since you could just overwrite the file completely.