Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 34 additions & 5 deletions gradle/versioning.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,44 @@ ext.getTag = { ->
return stdout.toString().trim().substring(1)
}

// 0.20.0-2-g000a42a -> 0.20.0-SNAPSHOT
// 0.20.1 -> 0.21.0
ext.getNextVersion = { String versionString ->
def split = versionString.split('\\.')
if (split.length != 3) {
throw new IllegalArgumentException("Expect a version to be semver (major.minor.patch), but got: " + versionString)
}
return split[0] + '.' + (Integer.parseInt(split[1]) + 1) + '.0'
}

// 0.20.1-2-g000a42a -> 0.21.0-SNAPSHOT
// 0.20.1-some-postfix-2-g000a42a -> 0.21.0-some-postfix-SNAPSHOT
// 0.20.0 -> 0.20.0
// Used to name jar files
ext.getVersionName = { ->
def split = getTag().split('-')
if (split.size() > 1) {
return split[0] + '-SNAPSHOT'
String tag = getTag()
def split = tag.split('-')
if (split.length > 2) {
if (split[split.length - 1].startsWith('g')) {
// we are not on tag, create a snapshot version
String result = getNextVersion(split[0])

//if the version/tag has any postfixes after -, we preserve the,
for (int i = 1; i < split.length - 2; i++) {
result += split[i]
}
return result + '-SNAPSHOT'

} else {
// the last element of describe should start with g according to git describe format
// if we are not exactly on a tag. If it doesn't - we are on a tag
return tag
}


} else {
//we are exactly on the tag, return the tag instead of SNAPSHOT
return tag
}
return split[0]
}

// 0.20.0-SNAPSHOT -> 0.20.0
Expand Down