forked from zowe/sample-spring-boot-api-service
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
39 lines (37 loc) · 1.1 KB
/
build.gradle
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
allprojects {
ext.getLastGitTag = { ->
try {
def stdout = new ByteArrayOutputStream()
exec {
commandLine 'git', 'describe', '--abbrev=0', '--tags'
standardOutput = stdout
}
return stdout.toString().trim()
} catch (ignored) {
return null
}
}
ext.getLastGitTagWithNewCommit = { ->
try {
def stdout = new ByteArrayOutputStream()
exec {
commandLine 'git', 'describe', '--tags'
standardOutput = stdout
}
return stdout.toString().trim()
} catch (ignored) {
return null
}
}
ext.getVersionFromGitTag = { ->
def pattern = ~/^v(\d{1,3})\.(\d{1,3})\.\d{1,4}$/
def lastTag = getLastGitTag() ?: 'v0.0.0'
if ((lastTag != null) && lastTag.matches(pattern) && (lastTag == getLastGitTagWithNewCommit())) {
return lastTag.substring(1)
}
else {
// See docs/releasing.md
return "0.0.0-SNAPSHOT"
}
}
}