forked from CraftTweaker/CraftTweaker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle.kts
282 lines (236 loc) · 9.1 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
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
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.text.SimpleDateFormat
import java.util.*
// Not sure how to do this without the buildscript block
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath("com.diluv.schoomp:Schoomp:1.2.5")
}
}
val minecraftVersion: String by project
val commonRunsEnabled: String by project
val commonClientRunName: String by project
val commonServerRunName: String by project
val forgeVersion: String by project
val forgeAtsEnabled: String by project
val fabricVersion: String by project
val fabricLoaderVersion: String by project
val modName: String by project
val modAuthor: String by project
val modId: String by project
val modJavaVersion: String by project
val zenCodeJavaVersion: String by project
val gitRepo: String by project
val modAvatar: String by project
val modVersion: String by project
plugins {
`java-library`
idea
id("com.blamejared.modtemplate") version ("3.0.0.37")
}
version = Utils.updatingVersion(modVersion)
allprojects {
repositories {
mavenCentral()
maven("https://repo.spongepowered.org/repository/maven-public/") {
name = "Sponge / Mixin"
}
maven("https://maven.blamejared.com") {
name = "BlameJared Maven"
}
maven("https://dvs1.progwml6.com/files/maven") {
name = "JEI"
content {
includeGroup("mezz.jei")
}
}
maven("https://maven.shedaniel.me") {
name = "REI"
content {
includeGroup("me.shedaniel")
includeGroup("me.shedaniel.cloth")
includeGroup("dev.architectury")
}
}
maven("https://maven.parchmentmc.org") {
name = "ParchmentMC"
}
}
// occasionally look to see if forge and fabric have fixed this...
tasks.withType<GenerateModuleMetadata> {
enabled = false
}
}
subprojects {
this.ext.set(
"zenCodeDeps",
setOf(
":CodeFormatter",
":CodeFormatterShared",
":JavaIntegration",
":JavaAnnotations",
":JavaBytecodeCompiler",
":JavaShared",
":Validator",
":Parser",
":CodeModel",
":Shared"
)
)
this.ext.set("zenCodeTestDeps", setOf(":ScriptingExample"))
// <editor-fold desc="ZenCode projects">
if (project.projectDir.parent == rootProject.file("ZenCode").absolutePath) {
apply(plugin = "java-library")
group = "org.openzen.zencode"
version = "0.3.8"
extensions.configure<JavaPluginExtension> {
toolchain.languageVersion.set(JavaLanguageVersion.of(zenCodeJavaVersion.toInt()))
withSourcesJar()
}
tasks.withType<JavaCompile> {
options.encoding = "UTF-8"
}
}
// </editor-fold>
// <editor-fold desc="Modloader projects">
else if (setOf("Common", "Forge", "Fabric").contains(project.name)) {
apply(plugin = "java")
apply(plugin = "idea")
val library by configurations.creating
configurations {
implementation.get().extendsFrom(library)
}
idea {
module {
excludeDirs.add(project.file("run"))
excludeDirs.add(project.file("run_server"))
}
}
sourceSets {
create("gametest") {
resources {
srcDirs.add(project.file("src/gametest/resources"))
}
compileClasspath += sourceSets.main.get().runtimeClasspath
runtimeClasspath += sourceSets.main.get().runtimeClasspath
}
}
dependencies {
// library(project(":Crafttweaker_Annotations"))
annotationProcessor(project(":Crafttweaker_Annotation_Processors"))
implementation("com.google.code.findbugs:jsr305:3.0.1")
"gametestImplementation"("com.google.truth:truth:1.1.3")
"gametestImplementation"("com.google.truth.extensions:truth-java8-extension:1.1.3")
// This is required for Truth since MC uses an old Guava version, however in 1.18 the game uses an updated version.
"gametestImplementation"("com.google.guava:guava:31.0.1-jre")
}
extensions.configure<JavaPluginExtension> {
toolchain.languageVersion.set(JavaLanguageVersion.of(modJavaVersion))
withJavadocJar()
withSourcesJar()
}
tasks.withType<JavaCompile> {
options.encoding = "UTF-8"
options.release.set(modJavaVersion.toInt())
options.compilerArgs.add("-Acrafttweaker.processor.document.output_directory=${rootProject.file("docsOut")}")
options.compilerArgs.add("-Acrafttweaker.processor.document.multi_source=true")
}
tasks {
compileTestJava {
options.isFork = true
options.compilerArgs.add("-XDenableSunApiLintControl")
}
jar {
manifest {
attributes(
"Specification-Title" to modName,
"Specification-Vendor" to modAuthor,
"Specification-Version" to archiveVersion,
"Implementation-Title" to project.name,
"Implementation-Version" to archiveVersion,
"Implementation-Vendor" to modAuthor,
"Implementation-Timestamp" to SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ").format(Date()),
"Timestamp" to System.currentTimeMillis(),
"Built-On-Java" to "${System.getProperty("java.vm.version")} (${System.getProperty("java.vm.vendor")})",
"Build-On-Minecraft" to minecraftVersion
)
}
}
}
tasks.withType<Javadoc> {
options {
// Javadoc defines this specifically as StandardJavadocDocletOptions
// but only has a getter for MinimalJavadocOptions, but let's just make sure to be safe
if (this is StandardJavadocDocletOptions) {
this.tags("docParam", "docEvent", "docShortDescription")
this.addStringOption("Xdoclint:none", "-quiet")
}
}
}
}
// </editor-fold>
// <editor-fold desc="Other projects">
else {
apply(plugin = "java-library")
// Any AP specific stuff can go here
}
// </editor-fold>
}
tasks.create("postDiscord") {
doLast {
try {
// Create a new webhook instance for Discord
val webhook = Webhook(
System.getenv("discordCFWebhook"),
"$modName CurseForge Gradle Upload"
)
// Craft a message to send to Discord using the webhook.
val message = Message()
message.username = modName
message.avatarUrl = modAvatar
message.content = "$modName $version for Minecraft $minecraftVersion 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, gitRepo).take(1000), false)
embed.color = 0xF16436
message.addEmbed(embed)
webhook.sendMessage(message)
} catch (e: IOException) {
project.logger.error("Failed to push CF Discord webhook.")
}
}
}