-
Notifications
You must be signed in to change notification settings - Fork 8
/
build.gradle.kts
124 lines (104 loc) · 2.58 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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
import dev.kordex.gradle.plugins.kordex.DataCollection
import java.util.*
plugins {
application
kotlin("jvm")
kotlin("plugin.serialization")
id("com.github.gmazzo.buildconfig")
id("com.github.jakemarsden.git-hooks")
id("com.github.johnrengelman.shadow")
id("dev.kordex.gradle.kordex")
id("io.gitlab.arturbosch.detekt")
id("net.kyori.blossom")
id("net.kyori.indra.git")
}
fun String.runCommand(
workingDir: File = File("."),
timeoutAmount: Long = 60,
timeoutUnit: TimeUnit = TimeUnit.SECONDS
): String = ProcessBuilder(split("\\s(?=(?:[^'\"`]*(['\"`])[^'\"`]*\\1)*[^'\"`]*$)".toRegex()))
.directory(workingDir)
.redirectOutput(ProcessBuilder.Redirect.PIPE)
.redirectError(ProcessBuilder.Redirect.PIPE)
.start()
.apply { waitFor(timeoutAmount, timeoutUnit) }
.run {
val error = errorStream.bufferedReader().readText().trim()
if (error.isNotEmpty()) {
throw Exception(error)
}
inputStream.bufferedReader().readText().trim()
}
group = "org.hyacinthbots.allium"
version = if ("git branch --show-current"
.runCommand(workingDir = rootDir)
.replace("/", ".") == "root") {
"1.0.0"
} else {
"1.0.1-build.local-" +
"git rev-parse --short=8 HEAD"
.runCommand(workingDir = rootDir) +
"-" +
"git branch --show-current"
.runCommand(workingDir = rootDir)
.replace("/", ".")
}
var buildTime = Date().time / 1000
sourceSets {
main {
blossom {
kotlinSources {
property("version", project.version.toString())
property("buildtime", buildTime.toString())
}
}
}
}
dependencies {
detektPlugins(libs.detekt)
implementation(libs.kotlin.stdlib)
implementation(libs.kx.ser)
implementation(libs.kx.ser.json)
implementation(libs.gson)
implementation(libs.doc.gen)
implementation(libs.kmongo)
// Logging dependencies
implementation(libs.jansi)
implementation(libs.logging)
implementation(libs.groovy)
implementation(libs.logback)
implementation(libs.logback.groovy)
}
gitHooks {
setHooks(
mapOf("pre-commit" to "detekt")
)
}
kordEx {
// The current LTS Java version
jvmTarget = 21
module("func-mappings")
module("pluralkit")
bot {
mainClass = "org.hyacinthbots.allium.AppKt"
dataCollection(DataCollection.Minimal)
}
}
tasks {
processResources {
inputs.property("version", project.version)
}
wrapper {
/*
* Update gradle by changing `gradleVersion` below to the new version,
* then run `./gradlew wrapper` twice to update the scripts properly.
*/
gradleVersion = "8.10"
distributionType = Wrapper.DistributionType.BIN
}
}
detekt {
buildUponDefaultConfig = true
autoCorrect = true
config.setFrom(rootProject.files("detekt.yml"))
}