-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.gradle.kts
286 lines (230 loc) · 8.39 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
283
284
285
286
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import java.nio.charset.StandardCharsets
plugins {
id("java-library")
id("maven-publish")
id("dev.architectury.loom") version "1.7-SNAPSHOT"
id("me.fallenbreath.yamlang") version "1.4.0"
id("org.jetbrains.kotlin.jvm") version "2.0.0"
id("me.modmuss50.mod-publish-plugin") version "0.8.3"
id("co.uzzu.dotenv.gradle") version "4.0.0"
}
fun prop(key: String) = property(key) as String
version = prop("mod_version")
group = prop("mod_group_id")
repositories {
mavenLocal()
maven("https://maven.neoforged.net")
maven("https://maven.parchmentmc.org")
// Regolith
maven("https://codeberg.org/EmmaTheMartian/regolith/raw/branch/main/repo/")
// Dapper
maven("https://codeberg.org/EmmaTheMartian/dapper/raw/branch/main/repo/")
// Kotlin For Forge
maven("https://thedarkcolour.github.io/KotlinForForge/")
// EMI
maven("https://maven.terraformersmc.com/")
// Legacy Landscape
maven("https://maven.muonmc.org/releases/")
// CC Tweaked
maven("https://maven.squiddev.cc") {
content {
includeGroup("cc.tweaked")
}
}
// Jade, AE2, Mekanism, Cable Facades, Fusion
exclusiveContent {
forRepository {
maven("https://api.modrinth.com/maven")
}
filter {
includeGroup("maven.modrinth")
}
}
}
base {
archivesName = prop("mod_id")
}
java {
toolchain.languageVersion = JavaLanguageVersion.of(21)
withSourcesJar()
withJavadocJar()
}
kotlin.compilerOptions.jvmTarget = JvmTarget.JVM_21
sourceSets {
main {
resources {
srcDir("src/generated/resources")
exclude("*.cache/")
}
}
create("data") {
kotlin {
srcDirs("src/data/kotlin")
}
compileClasspath += main.get().compileClasspath + main.get().output
runtimeClasspath += main.get().runtimeClasspath + main.get().output
}
}
tasks.compileKotlin {
source(sourceSets["data"].kotlin)
}
loom {
runs {
all {
vmArg("-XX:+AllowEnhancedClassRedefinition")
}
register("data") {
data()
source(sourceSets["data"])
programArgs("--all", "--mod", prop("mod_id"),
"--output", file("src/generated/resources/").absolutePath,
"--existing", file("src/main/resources/").absolutePath)
}
}
}
yamlang {
targetSourceSets = listOf(sourceSets.main.get())
inputDir = "assets/${prop("mod_id")}/lang"
}
dependencies {
// Shorthands for Modrinth maven dependencies
fun modrinth(id: String) = "maven.modrinth:$id:${prop("${id.replace('-', '_')}_version")}"
fun enabled(id: String) = prop("enable_$id") == "true"
minecraft("com.mojang:minecraft:${prop("minecraft_version")}")
@Suppress("UnstableApiUsage")
mappings(loom.layered {
officialMojangMappings()
parchment("org.parchmentmc.data:parchment-${prop("parchment_minecraft_version")}:${prop("parchment_mappings_version")}@zip")
})
neoForge("net.neoforged:neoforge:${prop("neo_version")}")
// Regolith
include(implementation("martian:regolith-neoforge:${prop("regolith_version")}")!!)
// Dapper (for datagen)
implementation("martian:dapper:${prop("dapper_version")}")
// KotlinForForge (for datagen)
implementation("thedarkcolour:kotlinforforge-neoforge:${prop("kff_version")}") {
// https://github.com/thedarkcolour/KotlinForForge/issues/103
exclude(group = "net.neoforged.fancymodloader", module = "loader")
}
// EMI
compileOnly("dev.emi:emi-neoforge:${prop("emi_version")}:api")
runtimeOnly("dev.emi:emi-neoforge:${prop("emi_version")}")
// Legacy Landscape
modLocalRuntime("gay.sylv.legacy_landscape:legacy_landscape:${prop("legacy_landscape_version")}") { isTransitive = false }
// ComputerCraft
forgeRuntimeLibrary("cc.tweaked:cobalt:0.9.3") // Gradle doesn't get this automatically from the CC Tweaked dependency, for whatever reason
modLocalRuntime("cc.tweaked:cc-tweaked-${prop("minecraft_version")}-forge:${prop("cc_version")}")
// Fusion
modImplementation(modrinth("fusion-connected-textures"))
if (enabled("jade"))
modLocalRuntime(modrinth("jade"))
if (enabled("ae2"))
modLocalRuntime(modrinth("ae2"))
if (enabled("mekanism"))
modLocalRuntime(modrinth("mekanism"))
if (enabled("cable_facades"))
modLocalRuntime(modrinth("cable-facades"))
}
// This block of code expands all declared replace properties in the specified resource targets.
// A missing property will result in an error. Properties are expanded using ${} Groovy notation.
val replaceProperties = mapOf(
"minecraft_version" to prop("minecraft_version"),
"minecraft_version_range" to prop("minecraft_version_range"),
"neo_version" to prop("neo_version"),
"neo_version_range" to prop("neo_version_range"),
"loader_version_range" to prop("loader_version_range"),
"mod_id" to prop("mod_id"),
"mod_name" to prop("mod_name"),
"mod_license" to prop("mod_license"),
"mod_version" to prop("mod_version"),
"mod_authors" to prop("mod_authors"),
"mod_description" to prop("mod_description"),
)
val generateModMetadata = tasks.register<ProcessResources>("generateModMetadata") {
inputs.properties(replaceProperties)
expand(replaceProperties)
from("src/main/templates")
into("build/generated/sources/modMetadata")
}
// Include the output of "generateModMetadata" as an input directory for the build
// this works with both building through Gradle and the IDE.
sourceSets.main.get().resources.srcDir(generateModMetadata)
// To avoid having to run "generateModMetadata" manually, make it run on every project reload
tasks.ideaSyncTask.configure {
dependsOn(generateModMetadata)
}
// Exclude the `data` source set from any jars build
tasks.withType<Jar>().configureEach {
exclude("martian/minefactorial/datagen/*")
}
publishing {
publications {
register<MavenPublication>("mavenJava") {
from(components["java"])
}
}
repositories {
maven("file://${project.projectDir}/repo")
}
}
publishMods {
type = STABLE
modLoaders.add("neoforge")
file = tasks.remapJar.get().archiveFile
additionalFiles.from(tasks.remapSourcesJar.get().archiveFile)
var changelogText = "# ${prop("version")}\n\n"
// Read the latest version from the changelog
changelogText += File(rootDir, "changelog.md")
.readText(StandardCharsets.UTF_8)
.split(Regex("^#(?!#).*$", RegexOption.MULTILINE))[1]
.trim()
changelog = changelogText
// dryRun = true
curseforge {
projectId = "1144883"
projectSlug = "minefactorial"
accessToken = env.CURSEFORGE_TOKEN.value
announcementTitle = "Get from CurseForge"
minecraftVersions.add("1.21.1")
javaVersions.add(JavaVersion.VERSION_21)
javaVersions.add(JavaVersion.VERSION_22)
clientRequired = true
serverRequired = true
optional("emi")
optional("fusion-connected-textures")
}
modrinth {
projectId = "4sjHMjq5"
accessToken = env.MODRINTH_TOKEN.value
announcementTitle = "Get from Modrinth"
minecraftVersions.add("1.21.1")
optional("emi")
optional("fusion-connected-textures")
}
github {
repository = "emmathemartian/minefactorial"
// My branches are named by the minecraft version they target
commitish = prop("minecraft_version")
accessToken = env.GITHUB_TOKEN.value
announcementTitle = "Get from GitHub"
allowEmptyFiles = true
}
discord {
val avatar = "https://raw.githubusercontent.com/EmmaTheMartian/minefactorial/refs/heads/1.21.1/src/main/resources/assets/minefactorial/icon.png"
webhookUrl = env.DISCORD_WEBHOOK_URL.value
username = "MineFactorial Build Bot"
avatarUrl = avatar
style {
look = "MODERN"
thumbnailUrl = avatar
}
}
}
// IDEA no longer automatically downloads sources/javadoc jars for dependencies, so we need to explicitly enable the behavior.
idea {
module {
isDownloadSources = true
isDownloadJavadoc = true
}
}