forked from isXander/Debugify
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.gradle.kts
More file actions
337 lines (286 loc) · 11.3 KB
/
build.gradle.kts
File metadata and controls
337 lines (286 loc) · 11.3 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
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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
plugins {
id("dev.isxander.modstitch.base") version "0.6.2-unstable"
id("me.modmuss50.mod-publish-plugin") version "0.8.4"
`maven-publish`
id("org.ajoberstar.grgit") version "5.3.2"
}
val debugifyVersion = "1.1"
modstitch {
minecraftVersion = "1.21.10"
modLoaderVersion = "0.18.0"
parchment {
mappingsVersion = "2025.10.12"
}
metadata {
modVersion = minecraftVersion.map { "$it+$debugifyVersion" }
modId = "debugify"
modName = "Debugify"
modDescription = "Fixes Minecraft bugs found on the bug tracker"
modCredits = """
j-Tai's TieFix - Code used licensed under LGPLv3
FlashyReese's Sodium Extra - Code used licensed under LGPLv3
Ampflower's 2x2 Surrounded Saplings Fix - Code used licensed under Zlib
NoahvdAa's Thorium - Code used licensed under LGPLv3
Moulberry's MoulberryTweaks - Code used licensed under MIT
""".trimIndent()
}
mixin {
addMixinsToModManifest = true
configs.register("debugify")
configs.register("debugify.client") { side = CLIENT }
}
loom {
configureLoom {
mixin.useLegacyMixinAp = false
splitEnvironmentSourceSets()
val gametest by sourceSets.registering {
compileClasspath += sourceSets.main.get().compileClasspath
runtimeClasspath += sourceSets.main.get().runtimeClasspath
compileClasspath += sourceSets["client"].compileClasspath
runtimeClasspath += sourceSets["client"].runtimeClasspath
}
//createProxyConfigurations(sourceSets["client"])
createProxyConfigurations(gametest.get())
mods.register("debugify") {
sourceSet(sourceSets["main"])
sourceSet(sourceSets["client"])
}
runs {
register("gametest") {
client()
ideConfigGenerated(true)
name("Game Test")
source(gametest.get())
}
listOf(named("client"), named("server")).forEach {
it {
vmArg("-Ddebugify.forceMacFixes=true")
vmArg("-Ddebugify.forceLinuxFixes=true")
vmArg("-Ddebugify.forceWindowsFixes=true")
}
}
}
}
}
}
repositories {
exclusiveContent {
forRepository { maven("https://maven.terraformersmc.com/releases") }
filter { includeGroup("com.terraformersmc") }
}
exclusiveContent {
forRepository { maven("https://maven.isxander.dev/releases") }
filter {
includeGroup("dev.isxander")
includeGroup("org.quiltmc.parsers")
}
}
}
val fabricApiVersion: String by project
val yaclVersion: String by project
val mixinExtrasVersion: String by project
val modMenuVersion: String by project
dependencies {
modImplementation(fabricApi.module("fabric-resource-loader-v0", fabricApiVersion))
modImplementation("net.fabricmc.fabric-api:fabric-api:$fabricApiVersion")
"modClientImplementation"("dev.isxander:yet-another-config-lib:$yaclVersion")
"modClientImplementation"("com.terraformersmc:modmenu:$modMenuVersion")
"gametestImplementation"(sourceSets.main.get().output)
"gametestImplementation"(sourceSets["client"].output)
"modGametestImplementation"(fabricApi.module("fabric-gametest-api-v1", fabricApiVersion))
}
java {
withSourcesJar()
}
publishMods {
displayName = modstitch.metadata.modVersion.map { "Debugify $it" }
version = modstitch.metadata.modVersion
file = tasks.remapJar.get().archiveFile
type = STABLE
modLoaders.add("fabric")
changelog = modstitch.minecraftVersion.zip(modstitch.metadata.modVersion) { mcVersion, modVersion ->
val header = file("changelogs/header.md")
.takeIf { it.exists() }
?.readText()
file("changelogs/$mcVersion/$modVersion.md")
.takeIf { it.exists() }
?.readText()
?.let { if (header != null) "$header\n\n$it" else it }
}
val modrinthId: String by project
if (modrinthId.isNotBlank() && hasProperty("modrinth.token")) {
modrinth {
projectId.set(modrinthId)
accessToken.set(findProperty("modrinth.token")?.toString())
minecraftVersions.add(modstitch.minecraftVersion)
requires { slug.set("yacl") }
requires { slug.set("fabric-api") }
optional { slug.set("modmenu") }
}
}
val curseforgeId: String by project
if (curseforgeId.isNotBlank() && hasProperty("curseforge.token")) {
curseforge {
projectId.set(curseforgeId)
accessToken.set(findProperty("curseforge.token")?.toString())
minecraftVersions.add(modstitch.minecraftVersion)
requires { slug.set("yacl") }
requires { slug.set("fabric-api") }
optional { slug.set("modmenu") }
}
}
val githubProject: String by project
if (githubProject.isNotBlank() && hasProperty("github.token")) {
github {
repository.set(githubProject)
accessToken.set(findProperty("github.token")?.toString())
commitish.set(grgit.branch.current().name)
}
}
}
publishing {
publications {
create<MavenPublication>("debugify") {
groupId = "dev.isxander"
artifactId = "debugify"
from(components["java"])
}
}
repositories {
if (hasProperty("XANDER_MAVEN_USER") && hasProperty("XANDER_MAVEN_PASS")) {
maven(url = "https://maven.isxander.dev/releases") {
credentials {
username = property("XANDER_MAVEN_USER")?.toString()
password = property("XANDER_MAVEN_PASS")?.toString()
}
}
} else {
println("Xander Maven credentials not satisfied")
}
}
}
val generatePatchedTable by tasks.registering {
val inputFile = rootProject.file(".bugs")
inputs.file(inputFile)
val outputFile = rootProject.file("PATCHED.md")
outputs.file(outputFile)
group = "debugify-utils"
doLast {
val inputContents = inputFile.readText()
val entries = parsePatchedFile(inputContents)
val patched = entries.filterIsInstance<PatchedFileEntry.Patched>()
val clientPatched = patched.filter { it.env == PatchedFileEntry.Patched.Environment.Client }
val serverPatched = patched.filter { it.env == PatchedFileEntry.Patched.Environment.Server }
fun generatePatchedRows(entries: List<PatchedFileEntry.Patched>) =
entries.joinToString("\n") { "- | ${it.type.friendlyName} | [${it.bugId}](https://mojira.dev/${it.bugId}) | ${getBugDescription(it.bugId)} |" }
val previous = entries.filterIsInstance<PatchedFileEntry.Previous>()
val timestamp = `java.time`.LocalDateTime.now().format(`java.time.format`.DateTimeFormatter.ISO_DATE_TIME)
val markdownTable = """
- <!--
- !!!! DO NOT UPDATE THIS FILE MANUALLY !!!!
- Generated by `./gradlew generatePatchedTable`
- Sourced from `${inputFile.name}`
- Generated $timestamp
- -->
-
- # List of Patched Bugs
- ## Unpatched in vanilla
- ### Client side
- | Type | Bug ID | Name |
- |------|--------|------|
${generatePatchedRows(clientPatched)}
- ### Server side (both)
- | Type | Bug ID | Name |
- |------|--------|------|
${generatePatchedRows(serverPatched)}
- ## Previously patched
- Bugs that this mod has patched in the past, but has since been fixed by a vanilla update.
- | Bug ID | Name | Fixed Version |
- |--------|------|---------------|
${previous.joinToString("\n") { "- | [${it.bugId}](https://mojira.dev/${it.bugId}) | ${getBugDescription(it.bugId)} | ${it.patchVersion} |" }}
""".trimMargin("-")
outputFile.parentFile.mkdirs()
outputFile.writeText(markdownTable)
}
}
data class MojiraBug(
val key: String,
val summary: String,
val status: String,
val confirmation_status: String,
val resolution: String,
val fix_versions: List<String>
) {
companion object {
fun fetch(bugId: String): MojiraBug? {
try {
val url = "https://mojira.dev/api/v1/issues/$bugId"
val response = `java.net`.URI(url).toURL().readText()
return com.google.gson.Gson().fromJson(response, MojiraBug::class.java)
} catch (e: Exception) {
e.printStackTrace()
return null
}
}
}
}
sealed class PatchedFileEntry(val bugNumber: Int) {
val bugId = "MC-$bugNumber"
class Patched(bugNumber: Int, val env: Environment, val type: Type) : PatchedFileEntry(bugNumber) {
enum class Environment(val friendlyName: String) {
Client("Client"), Server("Server");
companion object {
fun from(string: String): Environment? =
when (string) {
"client" -> Client
"server" -> Server
else -> null
}
}
}
enum class Type(val friendlyName: String) {
Basic("Basic"), Gameplay("Gameplay");
companion object {
fun from(string: String): Type? =
when (string) {
"basic" -> Basic
"gameplay" -> Gameplay
else -> null
}
}
}
}
class Previous(bugNumber: Int, val patchVersion: String) : PatchedFileEntry(bugNumber)
}
fun parsePatchedFile(contents: String): List<PatchedFileEntry> {
return contents.lineSequence()
.map { it.trim() }
.filter { it.isNotBlank() && !it.startsWith("#") }
.map { it.lowercase() }
.map { it.split(" ") }
.filter { it.size >= 2 }
.map { words ->
val command = words[0]
val bugNumber = words[1].toInt()
return@map when (command) {
"patched" -> {
if (words.size != 4) throw IllegalArgumentException("patched command must have exactly 4 words: got ${words.joinToString(" ")}")
val env = PatchedFileEntry.Patched.Environment.from(words[2])!!
val type = PatchedFileEntry.Patched.Type.from(words[3])!!
PatchedFileEntry.Patched(bugNumber, env, type)
}
"previous" -> {
if (words.size != 3) throw IllegalArgumentException("previous command must have exactly 3 words: got ${words.joinToString(" ")}")
val fixVersion = words[2]
PatchedFileEntry.Previous(bugNumber, fixVersion)
}
else -> throw IllegalArgumentException("Unknown command: $command")
}
}
.toList()
.sortedBy { it.bugNumber }
}
fun getBugDescription(bugId: String): String {
val mojiraBug = MojiraBug.fetch(bugId)
return mojiraBug?.summary ?: ""
}