-
Notifications
You must be signed in to change notification settings - Fork 15
/
build.gradle
54 lines (49 loc) · 1.38 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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
buildscript {
repositories {
mavenLocal()
jcenter()
mavenCentral()
}
dependencies {
classpath 'org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:3.0'
}
}
apply from: 'gradle/sonar.gradle'
apply from: 'gradle/generate-pom.gradle'
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"
}
}
}