-
Notifications
You must be signed in to change notification settings - Fork 3
/
build.gradle.kts
65 lines (53 loc) · 2.04 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
63
64
65
import java.io.ByteArrayOutputStream
import java.io.IOException
group = "net.janrupf.ultralight"
version = determineProjectVersion()
fun determineProjectVersion(): String {
// Attempt to read the version from the project properties
val propertyVersion = project.properties["ujr.version"]?.toString()
if (!propertyVersion.isNullOrEmpty()) {
return propertyVersion
}
// Else attempt to read the version from the commit hash
try {
val revStdoutCollector = ByteArrayOutputStream()
val revExecution = exec {
executable = "git"
args = listOf("rev-parse", "--short=16", "HEAD")
isIgnoreExitValue = true
standardOutput = revStdoutCollector
}
if (revExecution.exitValue == 0) {
val diffStdoutCollector = ByteArrayOutputStream()
val diffExecution = exec {
executable = "git"
args = listOf("diff", "--stat")
isIgnoreExitValue = true
standardOutput = diffStdoutCollector
}
val isDirty = diffExecution.exitValue != 0 || String(diffStdoutCollector.toByteArray()).trim().isNotEmpty()
return "0.0.0${if (isDirty) "-DIRTY" else ""}-${String(revStdoutCollector.toByteArray()).trim()}"
}
} catch (e: IOException) {
logger.warn("Failed to determine project version from git commit hash", e)
}
return "0.0.0-UNKNOWN"
}
subprojects {
plugins.withId("java") {
extensions.getByType(JavaPluginExtension::class.java).apply {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
withJavadocJar()
withSourcesJar()
}
tasks.withType(JavaCompile::class.java) {
options.encoding = "UTF-8"
}
tasks.named<Javadoc>("javadoc") {
(options as StandardJavadocDocletOptions).addBooleanOption("Xdoclint:-missing", true)
}
}
group = rootProject.group
version = rootProject.version
}