What is the preferred way to build a release in gradle? For those using Gradle over Maven, what is the process you are using for building a release?
I have been using Maven for years now and have begun to appreciate the strength and simplicity of gradle build script. I have written a gradle build script that builds my project exactly the same as with maven. Though I am missing the release process.
With maven release plugin the release is a two step process.
mvn release:prepare
mvn release:perform
It creates the git tag and two git commits for the release:
063f3d36b [maven-release-plugin] prepare for next development iteration
92d35d70f (tag: v1.0.0) [maven-release-plugin] prepare release v1.0.0
There is an gradle release plugin.
https://github.com/researchgate/gradle-release
$ gradle release -Prelease.useAutomaticVersion=true -Prelease.releaseVersion=1.0.0 -Prelease.newVersion=1.1.0-SNAPSHOT
Also an gradle git plugin that seems to have similar release feautures
https://github.com/ajoberstar/gradle-git
$ release -Prelease.scope=major -Prelease.stage=final
From what I see there is either using one of these gradle plugins to perform the release build, or do it manually.
$ sed -i 's/1.0.0-SNAPSHOT/1.0.0/g' build.gradle
$ git add build.gradle
$ git commit -m "Gradle Release v1.0.0"
$ git push
$ gradle build
$ git tag -a v1.0.0 -m "Gradle Release Build v1.0.0"
$ git push --tags
$ sed -i 's/1.0.0/1.1.0-SNAPSHOT/g' build.gradle
$ git add build.gradle
$ git commit -m "Gradle Release next development"
$ git push
This is a lot of work to do when we need to build a release.
Or perhaps have version always at 1.0.0-SNAPSHOT and not commit changes for version. Just change the version and build and create git tag for the release build. However we need some way to keep track on the previous version to increment, perhaps on a git tag.
$ gradle build -Prelease=true -PreleaseVersion=1.0.0
in build.gradle
if (release) {
version = releaseVersion
}