forked from CraftTweaker/CraftTweaker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle.kts
134 lines (106 loc) · 4.18 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
125
126
127
128
129
130
131
132
133
134
import com.blamejared.crafttweaker.gradle.Properties
import com.blamejared.crafttweaker.gradle.Versions
import com.blamejared.modtemplate.Utils
import com.diluv.schoomp.Webhook
import com.diluv.schoomp.message.Message
import com.diluv.schoomp.message.embed.Embed
import java.io.IOException
import java.util.*
// Not sure how to do this without the buildscript block
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath("com.diluv.schoomp:Schoomp:1.2.6")
}
}
plugins {
`java`
idea
id("com.blamejared.modtemplate")
}
version = Utils.updatingVersion(Versions.MOD)
tasks.wrapper {
//Define wrapper values here to not have to always do so when updating gradlew.properties
gradleVersion = "7.4.1"
distributionType = Wrapper.DistributionType.BIN
}
subprojects {
// We can't add this plugin to the ZC build.gradle
if (project.projectDir.parent == rootProject.file("ZenCode").absolutePath) {
apply(plugin = "com.blamejared.crafttweaker.zencode")
}
}
tasks.create("gameTest") {
dependsOn(":Fabric:runGameTest", ":Forge:GameTest")
group = "verification"
}
tasks.create("postDiscord") {
doLast {
try {
// Create a new webhook instance for Discord
val webhook = Webhook(
System.getenv("discordCFWebhook"),
"${Properties.MOD_NAME} CurseForge Gradle Upload"
)
// Craft a message to send to Discord using the webhook.
val message = Message()
message.username = Properties.MOD_NAME
message.avatarUrl = Properties.MOD_AVATAR
message.content = "${Properties.MOD_NAME} $version for Minecraft ${Versions.MINECRAFT} has been published!"
val embed = Embed()
val downloadSources = StringJoiner("\n")
if (project(":Fabric").ext.has("curse_file_url")) {
downloadSources.add("<:fabric:932163720568782878> [Fabric](${project(":Fabric").ext.get("curse_file_url")})")
}
if (project(":Forge").ext.has("curse_file_url")) {
downloadSources.add("<:forge:932163698003443804> [Forge](${project(":Forge").ext.get("curse_file_url")})")
}
downloadSources.add(
"<:maven:932165250738970634> `\"${project(":Common").group}:${project(":Common").base.archivesName.get()}:${
project(":Common").version
}\"`"
)
downloadSources.add(
"<:maven:932165250738970634> `\"${project(":Fabric").group}:${project(":Fabric").base.archivesName.get()}:${
project(":Fabric").version
}\"`"
)
downloadSources.add(
"<:maven:932165250738970634> `\"${project(":Forge").group}:${project(":Forge").base.archivesName.get()}:${
project(":Forge").version
}\"`"
)
// Add Curseforge DL link if available.
val downloadString = downloadSources.toString()
if (downloadString.isNotEmpty()) {
embed.addField("Download", downloadString, false)
}
// Just use the Forge changelog for now, the files are the same anyway.
embed.addField("Changelog", Utils.getCIChangelog(project, Properties.GIT_REPO).take(1000), false)
embed.color = 0xF16436
message.addEmbed(embed)
webhook.sendMessage(message)
} catch (e: IOException) {
project.logger.error("Failed to push CF Discord webhook.")
}
}
}
val apDir = "CraftTweaker-Annotation-Processors";
tasks.create("checkoutAP") {
doFirst {
if (!rootProject.file(apDir).exists() || (rootProject.file(apDir).listFiles() ?: arrayOf()).isEmpty()) {
exec {
commandLine("git", "clone", "https://github.com/CraftTweaker/CraftTweaker-Annotation-Processors.git")
}
} else {
throw GradleException("$apDir folder already exists and is not empty!")
}
}
}
tasks.create<Delete>("clearAP") {
doFirst {
delete(rootProject.file(apDir))
}
}