-
Notifications
You must be signed in to change notification settings - Fork 11
/
build.gradle
34 lines (32 loc) · 1.08 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
allprojects {
// This can get extracted into a root build.gradle if needed
ext {
getLatestTag = {
new ByteArrayOutputStream().withStream { os ->
exec {
executable = "git"
args = ["describe", "--tags", "--abbrev=0"]
standardOutput = os
}
return os.toString().trim()
}
}
getCurrentCommitCount = {
new ByteArrayOutputStream().withStream { os ->
exec {
executable = "git"
args = ["rev-list", "--all", "--count"]
standardOutput = os
}
return os.toString().trim()
}
}
}
try {
project.version = "${project.ext.getLatestTag()}-${project.ext.getCurrentCommitCount()}"
} catch (Exception ignored) {
println('Either git is not set up properly, or there is no tag yet in the repository. Falling back to version \'0\'')
project.version = '0'
}
project.group = 'michiruf'
}