Search code examples
spring-bootgradlesemantic-versioninggradle-release-plugin

Can gradle-release-plugin be configured to use SemVer?


I have a Spring-Boot Gradle 4.10.3 project which is currently working fine. It uses gradle-release plugin for releases and version management.

However, I now have a new requirement that the artifacts generated for this project adhere to SemVer conventions. I know there are SemVer Gradle plugins, but I don't want to retool my entire release process if I don't have to. It would be great if gradle-release would let me specify a filename pattern.

The config docs mention a parameter called versionPatterns, which seems like it might be helpful. But I can't figure out how to modify the example given:

versionPatterns = [ /(\d+)([^\d]*$)/: { Matcher m, Project p -> m.replaceAll("${(m0 as int) + 1}${m[0][2]}") } ]

So, what I need is my file name to change from:

AppName-1.2.3-SNAPSHOT.jar

To:

AppName.1.2.3-SNAPSHOT.jar

So really it seems like simply a matter of replacing the first dash with a dot.

Can this be done with gradle-release config? If not, is there an easier way? I would like to continue using gradle-release plugin, because it is already wired in for all of my processes.


Solution

  • I seem to have achieved my goal by configuring the bootJar section.

    I'm using an older Gradle version, so I am using some deprecated properties. But adding the following to bootJar seems to be doing the trick. Still interested in other/better ideas.

    archiveName = "$baseName.$version.$extension"