-
Notifications
You must be signed in to change notification settings - Fork 65
/
common.gradle
76 lines (69 loc) · 2.28 KB
/
common.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
configurations.all {
resolutionStrategy.eachDependency { details ->
if (details.requested.group == 'org.projectlombok') {
details.useVersion "1.18.20"
}
}
}
ext.generateVersionNumberString = { ->
StringBuilder stringBuilder = new StringBuilder()
stringBuilder.append((new Date()).format('21yyMMddHH'))
return stringBuilder.toString()
}
ext.generateTimestamp = { ->
StringBuilder stringBuilder = new StringBuilder()
stringBuilder.append((new Date()).getTime())
stringBuilder.append("L")
return stringBuilder.toString()
}
ext.generateRandomUUID = { ->
StringBuilder stringBuilder = new StringBuilder()
stringBuilder.append('"' + UUID.randomUUID().toString() + '"')
return stringBuilder.toString()
}
ext.generateVersionName = { ->
StringBuilder stringBuilder = new StringBuilder()
try {
def stdout = new ByteArrayOutputStream()
exec {
commandLine 'git', 'describe', '--always'
standardOutput = stdout
}
String commitObject = stdout.toString().trim()
try {
stdout = new ByteArrayOutputStream()
exec {
commandLine 'git', 'describe', '--tags'
standardOutput = stdout
}
//stringBuilder.append(stdout.toString().trim())
//stringBuilder.append("-")
} catch (ignored) {
// no tags
}
stringBuilder.append(commitObject)
stdout = new ByteArrayOutputStream()
exec {
commandLine 'git', 'rev-parse', '--show-toplevel'
standardOutput = stdout
}
if (stdout.toString().trim().contains("xDrip-Experimental")) {
stringBuilder.append("-experimental")
}
stdout = new ByteArrayOutputStream()
exec {
commandLine 'git', 'rev-parse', '--abbrev-ref', 'HEAD'
standardOutput = stdout
}
String branch = stdout.toString().trim()
if (!branch.equals("master")) {
stringBuilder.append('-')
stringBuilder.append(branch)
}
} catch (ignored) {
return "NoGitSystemAvailable"
}
stringBuilder.append('-')
stringBuilder.append((new Date()).format('yyyy.MM.dd'))
return stringBuilder.toString()
}