-
Notifications
You must be signed in to change notification settings - Fork 52
/
build.gradle.kts
62 lines (52 loc) · 1.41 KB
/
build.gradle.kts
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
import org.gradle.process.internal.ExecException
import java.io.ByteArrayOutputStream
plugins {
id("java")
}
val git : String = versionBanner()
val builder : String = builder()
ext["git_version"] = git
ext["builder"] = builder
subprojects {
apply(plugin = "java")
apply(plugin = "java-library")
repositories {
mavenCentral()
}
tasks.processResources {
filteringCharset = "UTF-8"
filesMatching(arrayListOf("custom-fishing.properties")) {
expand(rootProject.properties)
}
filesMatching(arrayListOf("*.yml", "*/*.yml")) {
expand(
Pair("project_version", rootProject.properties["project_version"]),
Pair("config_version", rootProject.properties["config_version"])
)
}
}
}
fun versionBanner(): String {
val os = ByteArrayOutputStream()
try {
project.exec {
commandLine = "git rev-parse --short=8 HEAD".split(" ")
standardOutput = os
}
} catch (e: ExecException) {
return "Unknown"
}
return String(os.toByteArray()).trim()
}
fun builder(): String {
val os = ByteArrayOutputStream()
try {
project.exec {
commandLine = "git config user.name".split(" ")
standardOutput = os
}
} catch (e: ExecException) {
return "Unknown"
}
return String(os.toByteArray()).trim()
}