-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.gradle.kts
More file actions
98 lines (85 loc) · 2.63 KB
/
build.gradle.kts
File metadata and controls
98 lines (85 loc) · 2.63 KB
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
import java.nio.file.Files
import java.nio.file.Paths
import java.nio.file.StandardOpenOption
plugins {
kotlin("jvm") version "2.3.0-RC3"
id("com.gradleup.shadow") version "8.3.0"
id("xyz.jpenilla.run-paper") version "2.3.1"
}
group = "xyz.devcmb"
version = "1.0"
repositories {
mavenCentral()
maven("https://repo.papermc.io/repository/maven-public/") {
name = "papermc-repo"
}
maven("https://jitpack.io")
maven("https://mvn.wesjd.net/") {
name = "mvn-wesjd-repo"
}
}
dependencies {
compileOnly("io.papermc.paper:paper-api:1.21.8-R0.1-SNAPSHOT")
implementation("com.github.29cmb:InvControl:v0.1.6")
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
implementation("net.wesjd:anvilgui:1.10.11-SNAPSHOT")
}
tasks {
runServer {
// Configure the Minecraft version for our task.
// This is the only required configuration besides applying the plugin.
// Your plugin's jar (or shadowJar if present) will be used automatically.
dependsOn("build")
minecraftVersion("1.21.8")
}
}
val targetJavaVersion = 21
kotlin {
jvmToolchain(targetJavaVersion)
}
tasks.build {
dependsOn("shadowJar")
dependsOn("updateVersion")
}
fun padLeftZeros(inputString: String, length: Int): String {
if (inputString.length >= length) return inputString
val sb = StringBuilder()
while (sb.length < length - inputString.length) {
sb.append('0')
}
sb.append(inputString)
return sb.toString()
}
tasks.register("updateVersion") {
doLast {
val versionFile = file("src/main/kotlin/xyz/devcmb/achievementsMC/Constants.kt")
val versionCounterFile = file("versionCounter.txt")
val newVersion = project.version.toString()
var counter = 0
if (versionCounterFile.exists()) {
counter = versionCounterFile.readText().trim().toInt(16)
}
counter++
val hexCounter = counter.toString(16)
val updatedVersion = "$newVersion-${padLeftZeros(hexCounter, 6)}"
val content = versionFile.readText()
val updatedContent = content.replace(
Regex("""(const val VERSION: String = ")([^"]+)(")"""),
"$1$updatedVersion$3"
)
Files.write(
Paths.get(versionFile.toURI()),
updatedContent.toByteArray(),
StandardOpenOption.TRUNCATE_EXISTING
)
versionCounterFile.writeText(hexCounter)
}
}
tasks.processResources {
val props = mapOf("version" to version)
inputs.properties(props)
filteringCharset = "UTF-8"
filesMatching("plugin.yml") {
expand(props)
}
}