Using Gradle to replicate maven branch and release

I’m moving from Maven to Gradle and have been happy so far. However, I’m stuck on the correct workflow to replicate maven branch and maven release.

My git workflow is setup like this:

The most recent SNAPSHOT code is on main, once we are at a point were we’d like to release we use mvn branch to create a “release” branch named something like release-2.0 (also we would set main to 2.1.0-SNAPSHOT). Then we put bug fixes, etc on that branch as needed and we use mvn release to tag and create releases on that branch as needed. etc.

I’m trying to use the nebula release plugin as a replacement and I think I have a handle around how it auto increments versions and creates tags, etc. But there is nothing documented about how to work on branches. This is my central problem.

It seems like maybe I need to manually create my branch and set a tag there (and on main) and then run my nebula release?

Is there some overall “accepted” way to do this? Maybe Nebula isn’t it? Any help would be greatly appreciated.

There are many opinions out there about where to get version numbers from and how to do the release process concretely, so there will hardly ever be an “overall accepted” or “correct” or even idiomatic way.

I personally prefer to use the GitHub - researchgate/gradle-release: gradle-release is a plugin for providing a Maven-like release process for projects using Gradle plugin which also happens to be made to be similar to the Maven release plugin, so might feel more familiar to you.

It has no branching functionality though.
But you could probably easily do that yourself with a custom task using JGit for example or similar if there is no plugin for that purpose.

Thanks so much for the info. I looked around for a plugin to do the branch in an automated way (ie. figure out the version to set the branch name to and set a tag there, all based on incrementing the last version tag found on main, etc) but haven’t found it yet…

Am I going about this the wrong way? This feels like a pretty common use case and I’m feeling that by not seeing anything to solve it, I must be approaching this incorrectly…

As I said, many opinions out there.

I for example thing that determining versions from VCS is horribly wrong in any way, for example if you want to build a detached worktree or similar.

I prefer maintaining the version in gradle.properties how I see fit and on release there the plugin increases it without any need to look at any Git state for determining any version. :slight_smile:

yes i’m likely going to do the same, but what about branches? You can’t keep everything on main… Do you automate making branches in some way?

No, the projects where I use it do not need release branches, and if I need a branch for a backport, I’ll create them ad-hoc when needed.

thanks… maybe someone else does use branches… :crossed_fingers: