researchgate / gradle-release

gradle-release is a plugin for providing a Maven-like release process for projects using Gradle
MIT License
863 stars 223 forks source link

How to customise with version part is bumped #307

Closed eloo closed 5 years ago

eloo commented 5 years ago

Hi, i'm trying to get the version bump working for minor version part but i'm not getting it to work :/ My guess was that i need to update the versionPattern but i didn't achieve any proper result. Maybe you have a hint for me or is it simply not possible?

What i want to to is that the version update will produce the following: 1.2.3 -> 1.3.0 or a easy solution could also be 1.2.0 -> 1.3.0

Thanks

Hillkorn commented 5 years ago

Try this one /(\d+)\.\d+([^\d]*$)/: { Matcher m, Project p -> m.replaceAll("${(m[0][1] as int) + 1}.0${m[0][3] ? m[0][3] : ""}") } It should work with and without SNAPSHOT suffix

eloo commented 5 years ago

just tested. working as expected. maybe you can add this to the documentation?

eloo commented 5 years ago

I'm now using the following to make version bumps for both possible based on the commandline args. maybe thats also interesting for you

release {
    if (project.hasProperty("releaseMinor")) {
        versionPatterns = [
                /(\d+)\.\d+([^\d]*$)/: { Matcher m, Project p -> m.replaceAll("${(m[0][1] as int) + 1}.0${m[0][3] ? m[0][3] : ""}") }
        ]
    } else {
        versionPatterns = [
                /(\d+)([^\d]*$)/: { Matcher m, Project p -> m.replaceAll("${(m[0][1] as int) + 1}${m[0][2]}") }
        ]
    }
}