-
Notifications
You must be signed in to change notification settings - Fork 0
/
utils.gradle
29 lines (26 loc) · 861 Bytes
/
utils.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
ext {
/**
* Outputs the latest commit's git shorthash. Requires `git` to be present as it executes `git` command and
* capture its output.
*
* @return Latest commit git shorthash.
*/
gitShortHash = { ->
def stdout = new ByteArrayOutputStream()
exec {
commandLine 'git', 'rev-parse', '--short', 'HEAD'
standardOutput = stdout
}
stdout.toString().trim()
}
/**
* Wraps over Scala libraries to append correct Scala version (i.e. with _2.13 suffix)
*
* @param dependency Dependency declaration.
* @returns Dependency declaration for the correct Scala version.
*/
scala = { String dependency ->
def (groupId, artifactId, version) = dependency.tokenize(':')
"${groupId}:${artifactId}_${scalaLibVersion}:${version}"
}
}