Jaume Suñer Mut
Jaume Suñer Mut

Reputation: 401

gradle release plugin automatic version pattern

I'm using gradle-release-plugin with jenkins and I want use

gradle release -Prelease.useAutomaticVersion=true

to automatic increase version.

But this automatic move the ".patch" number (assume major.minor.patch version) and I'm trying to move the ".minor" number.

For example if release 1.3.17 then newVersion 1.4.0-SNAPSHOT

I would change this automatic replace without use the release.releaseVersion and release.newVersion

It could be done with the plugin configuration versionPatterns ?

Maybe using this pattern /[.]*\.(\d+)\.(\d+)[.]*/ ?

Upvotes: 5

Views: 3477

Answers (1)

Jaume Suñer Mut
Jaume Suñer Mut

Reputation: 401

Auto answer...

After some research and tests I could move the minor version number (assume major.minor.patch version) with the param release.useAutomaticVersion=true

Just need to configure the versionPatterns plugin parameter with this closure:

versionPatterns = [
        // Increments minor number: "2.5.17-SNAPSHOT" => "2.6.0-SNAPSHOT"
        /[.]*\.(\d+)\.(\d+)[.]*/: { Matcher m, Project p -> m.replaceAll(".${(m[0][1] as int) + 1}.0") }
    ]

Really it isn't the only change needed in the build.gradle, this closure code depends to add this import previously:

import java.util.regex.Matcher

Upvotes: 12

Related Questions