Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

versionPatterns support with Kotlin dsl #342

Open
santbob opened this issue Oct 17, 2020 · 1 comment
Open

versionPatterns support with Kotlin dsl #342

santbob opened this issue Oct 17, 2020 · 1 comment

Comments

@santbob
Copy link

santbob commented Oct 17, 2020

One of our projects is using Kotlin DSL instead of Groovy-based syntax and our Jenkins Paved path setup uses this release plugin.
I need a way to convert

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

to a compatible Kotlin DSL version.

please suggest how to go about it.

@cjaehnen
Copy link

@santbob

I ran into a similar issue. I was able to solve it using the KotlinClosure2, which creates a Groovy closure that provides 2 parameters. I prefer to auto-increment the minor version automatically instead of the patch version, as most of my releases contain new features. Below is my release plugin configuration when running ./gradlew clean release -Prelease.useAutomaticVersion=true

release {
    versionPatterns = mapOf(
        // Increments 1.1.1 to 1.2.0-SNAPSHOT
        """[.]*\.(\d+)\.(\d+)[.]*""" to KotlinClosure2<Matcher, Project, String>({ matcher, project ->
            matcher.replaceAll(".${(matcher.group(0)[1]) + 1}.0")
        })
    )
    git {
        requireBranch = ""
        pushToRemote = "origin"
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants