-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathstonecutter.gradle
More file actions
107 lines (83 loc) · 3.47 KB
/
stonecutter.gradle
File metadata and controls
107 lines (83 loc) · 3.47 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
plugins {
id "me.gravityio.discord-webhook" version "0.0.3"
}
plugins.apply "dev.kikugie.stonecutter"
stonecutter.active "1.21.11" /* [SC] DO NOT EDIT */
Properties secrets = new Properties()
rootProject.file("secrets.properties").withInputStream { secrets.load(it) }
List<String> allVersions = new ArrayList<>()
String webhookUrl = secrets.get("discord_webhook").toString()
rootProject.ext.data = new LinkedHashMap<String, UploadData>()
rootProject.ext.changelog = file("CHANGELOG.md").text
stonecutter.versions.forEach {
allVersions.add(it.project)
rootProject.ext.data.put(it.project, new UploadData())
}
stonecutter.registerChiseled tasks.register("chiseledBuild", stonecutter.chiseled) {
setGroup "project"
ofTask "build"
}
stonecutter.registerChiseled tasks.register("chiseledPublish") {
group = "project"
chiseledDepends(it, "publishMod", allVersions)
doLast {
onPublish(webhookUrl, allVersions)
}
}
stonecutter.registerChiseled tasks.register("selectivePublish") {
setGroup "project"
chiseledDepends(it, "publishMod", "1.21.6")
doLast {
onPublish(webhookUrl, "1.21.6")
}
}
tasks.register("activeBuild") {
group = "project"
activeDepend(it, "build")
}
tasks.register("activePublish") {
group = "project"
activeDepend(it, "publishMod")
doLast {
onPublish(webhookUrl, stonecutter.current.project)
}
}
def onPublish(String webhookUrl, List<String> toPublishList) {
onPublish(webhookUrl, toPublishList.toArray(String[]::new))
}
def onPublish(String webhookUrl, String... toPublishArray) {
def message = ""
def mdSlug = "viewboboptions"
def cfSlug = "viewboboptions"
def issueChannel = "https://discord.com/channels/1112046604183162961/1245460372270612612"
def mentionId = "1277913050959319050"
toPublishArray.each {
UploadData upData = rootProject.ext.data.get(it)
message += "# $rootProject.mod_name ${rootProject.mod_version}+${it} Update ([Modrinth](<https://modrinth.com/mod/${mdSlug}/version/${upData.modrinthFileId}>) | [Curseforge](<https://curseforge.com/minecraft/mc-mods/${cfSlug}/files/${upData.curseFileId}>))\n"
}
message += "$rootProject.ext.changelog\n\n"
// message += "**To view the details of the changelog visit the [Modrinth changelog page](<https://modrinth.com/mod/${mdSlug}/changelog>) or the [CurseForge files page](<https://curseforge.com/minecraft/mc-mods/${cfSlug}/files/${rootProject.ext.data.firstEntry().value.curseFileId}>)**\n"
message += "**As always report any issues on my [GitHub](<${rootProject.mod_sources}>) or in ${issueChannel}**\n"
message += "<@&${mentionId}>"
rootProject.file("temp").mkdir()
rootProject.file("temp/discord.md").write(message)
def config = discord_webhook.prepare(webhookUrl)
config.content(message)
discord_webhook.send()
}
def activeDepend(Task task, String subtaskName) {
task.dependsOn(project(stonecutter.current.project).tasks.named(subtaskName).get())
}
def chiseledDepends(Task task, String subtaskName, List<String> versions) {
chiseledDepends(task, subtaskName, versions.toArray(String[]::new))
}
def chiseledDepends(Task task, String subtaskName, String... versions) {
def setupTask = tasks.named("chiseledStonecutter").get()
task.dependsOn(setupTask)
versions.each {
def proj = rootProject.project(it)
def subtask = proj.tasks.named(subtaskName).get()
task.dependsOn(subtask)
subtask.mustRunAfter(setupTask)
}
}