-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathfunctions.gradle
More file actions
49 lines (40 loc) · 1.19 KB
/
functions.gradle
File metadata and controls
49 lines (40 loc) · 1.19 KB
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
import java.text.SimpleDateFormat
gradle.allprojects {
ext.gitSha = {
def p = 'git rev-parse HEAD'.execute([], project.rootDir)
p.waitFor()
if (p.exitValue() != 0) {
throw new RuntimeException(p.errorStream.text)
}
return p.text.trim()
}
ext.gitTimestamp = {
def p = 'git log -n 1 --format=%at'.execute([], rootDir)
p.waitFor()
if (p.exitValue() != 0) {
throw new RuntimeException(p.errorStream.text)
}
return p.text.trim()
}
ext.gitLocalRef = {
def p = './scripts/git_ref'.execute([], rootDir)
p.waitFor()
if (p.exitValue() != 0) {
throw new RuntimeException(p.errorStream.text)
}
return p.text.trim()
}
ext.gitIsClean = {
def p = './scripts/git_clean'.execute([], rootDir)
p.waitFor()
if (p.exitValue() != 0) {
throw new RuntimeException(p.errorStream.text)
}
return p.text.trim()
}
ext.buildTime = {
def df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'")
df.setTimeZone(TimeZone.getTimeZone("UTC"))
return df.format(new Date())
}
}