forked from txnimc/sol_valheim
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle
309 lines (243 loc) · 9.33 KB
/
build.gradle
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
plugins {
id "architectury-plugin" version "${arch_plugin_version}"
id "dev.architectury.loom" version "${loom_version}" apply false
id "io.github.juuxel.loom-vineflower" version "${vineflower_version}" apply false
id "io.github.pacifistmc.forgix" version "${forgix_version}"
id "me.modmuss50.mod-publish-plugin" version "0.3.4" apply false // https://github.com/modmuss50/mod-publish-plugin
}
// These are the access wideners depending on the minecraft version
def mcVersionToAccessWidenerVersion = [
"1.19.2": "1_19_2",
"1.20.1": "1_20_1",
]
ext.set("access_wideners", mcVersionToAccessWidenerVersion)
loadProperties()
makeAccessWidener()
defineMixins()
forgix {
group = maven_group
mergedJarName = "${modid}-${mod_version}${getBuildNumber()}+mc${minecraft_version}.jar"
outputDir = "build/libs/merged"
}
architectury {
minecraft = minecraft_version
}
subprojects {
apply plugin: "dev.architectury.loom"
apply plugin: "io.github.juuxel.loom-vineflower"
def isForge = it == project(":forge")
def isFabric = it == project(":fabric")
def isCommon = it == project(":common")
def awFile = project(":common").file("src/main/resources/${modid}.accesswidener")
loom {
silentMojangMappingsLicense()
if(awFile.exists()) {
accessWidenerPath = awFile
if(isForge) {
forge {
convertAccessWideners = true
extraAccessWideners.add loom.accessWidenerPath.get().asFile.name
}
}
}
runs {
remove server
}
runs.configureEach {
vmArg("-Dmixin.debug.export=true")
vmArg("-Dmixin.env.remapRefMap=true")
vmArg("-Dmixin.env.refMapRemappingFile=${projectDir}/build/createSrgToMcp/output.srg")
}
}
configurations {
addJar
shade
addJarCompile
addJarRuntime
addJarEverywhere
if (!isCommon) {
include.extendsFrom addJar
}
if(isForge)
forgeRuntimeLibrary.extendsFrom addJar
compileOnly.extendsFrom addJarCompile
annotationProcessor.extendsFrom addJarCompile
implementation.extendsFrom addJarRuntime
api.extendsFrom addJarEverywhere
addJar.extendsFrom addJarCompile
addJar.extendsFrom addJarRuntime
addJar.extendsFrom addJarEverywhere
implementation.extendsFrom shade
}
repositories {
mavenCentral()
maven { url "https://maven.parchmentmc.org" }
maven { url "https://maven.quiltmc.org/repository/release" }
maven {
url "https://maven.tterrag.com/"
content {
includeGroup("com.jozufozu.flywheel")
includeGroup("com.tterrag.registrate")
includeGroup("com.simibubi.create")
}
}
maven { // modrinth
url "https://api.modrinth.com/maven"
content { includeGroup "maven.modrinth" }
}
maven { // curseforge
url "https://www.cursemaven.com"
content { includeGroup "curse.maven" }
}
}
dependencies {
minecraft "com.mojang:minecraft:${rootProject.minecraft_version}"
mappings(loom.layered {
it.mappings("org.quiltmc:quilt-mappings:${rootProject.minecraft_version}+build.${rootProject.quilt}:intermediary-v2")
it.parchment("org.parchmentmc.data:parchment-${rootProject.minecraft_version}:${rootProject.parchment}@zip")
it.officialMojangMappings { nameSyntheticMembers = false }
})
annotationProcessor "systems.manifold:manifold-preprocessor:${rootProject.manifold_version}"
if (isFabric) {
modImplementation("me.shedaniel.cloth:cloth-config-fabric:${rootProject.cloth_config_version}")
}
if (isForge) {
modImplementation("me.shedaniel.cloth:cloth-config-forge:${rootProject.cloth_config_version}")
modRuntimeOnly("curse.maven:farmers-delight-398521:${rootProject.farmers_delight}")
}
}
processResources {
def properties = [
id : modid,
aw : access_widener,
version : mod_version,
minecraft_version: minecraft_version,
display_name : display_name,
forge : forge.split("\\.")[0],
fabric : fabric,
fabric_api : fabric_api
]
inputs.properties properties
filesMatching("architectury.common.json") {
expand properties
}
filesMatching("fabric.mod.json") {
expand properties
}
filesMatching("META-INF/mods.toml") {
expand properties
}
}
}
allprojects {
apply plugin: "java"
apply plugin: "architectury-plugin"
apply plugin: "maven-publish"
archivesBaseName = rootProject.modid
version = rootProject.mod_version + getBuildNumber()
group = rootProject.maven_group
repositories {
maven { url 'https://oss.sonatype.org/content/repositories/snapshots/' } // manifold
maven { url 'https://jitpack.io' } // idk a lot of stuff
}
tasks.withType(JavaCompile).configureEach {
options.encoding = "UTF-8"
options.release = 17
options.compilerArgs += ['-Xplugin:Manifold']
}
java {
withSourcesJar()
}
}
static def getBuildNumber() {
String buildNumber = System.getenv("GITHUB_RUN_NUMBER")
return (buildNumber != null ? "-${buildNumber}" : "")
}
/* Cursed stuff is defined below! Beware of dog */
// Defines the preprocessors
def setupManifoldProcessors(List<String> mcVers, int mcIndex) {
def redefineList = new ArrayList<String>()
for (int i = 0; i < mcVers.size(); i++) {
String mcStr = "MC_" + mcVers.get(i).replace(".", "_")
if (mcIndex < i)
redefineList.add("PRE_$mcStr")
if (mcIndex <= i)
redefineList.add("PRE_CURRENT_$mcStr")
if (mcIndex == i)
redefineList.add(mcStr)
if (mcIndex > i)
redefineList.add("POST_$mcStr")
if (mcIndex >= i)
redefineList.add("POST_CURRENT_$mcStr")
}
StringBuilder sb = new StringBuilder()
.append("# DO NOT EDIT\n")
.append("# Generated by the build script. Change mcVer property to change minecraft version.\n\n")
for (String redefinedVersion : redefineList) {
sb.append(redefinedVersion).append("=\n")
}
new File(projectDir, "build.properties").text = sb.toString()
}
// Loads the properties for each version & sets up the preprocessors
def loadProperties() {
def mcVersion = ""
def mcVers = mc_versions.split(", ")
int mcIndex = -1
println "Avalible Minecraft Versions: ${mc_versions}"
if (project.hasProperty("mcVer")) {
mcVersion = mcVer
mcIndex = Arrays.asList(mcVers).indexOf(mcVer)
}
if (mcIndex == -1) {
println "Defaulting to ${rootProject.default_mc_version} since the set mcVer is invalid."
println "Use -PmcVer='${rootProject.default_mc_version}' or edit gradle.properties to set the minecraft version."
mcVersion = default_mc_version
mcIndex = Arrays.asList(mcVers).indexOf(default_mc_version)
}
println "Using " + mcVersion + ".properties."
def properties = new Properties()
properties.load(new FileInputStream("$rootProject.rootDir/"+"$mcVersion"+".properties"))
properties.each { property ->
rootProject.ext.set(property.key, property.value)
}
setupManifoldProcessors(Arrays.asList(mcVers), mcIndex)
rootProject.ext.set("access_widener_version", rootProject.access_wideners.get(mcVersion))
}
// Sets up the accesswideners
def makeAccessWidener() {
def accessWidenerFile = project(":common").file("src/main/resources/${modid}.accesswidener")
def versionAccessWidenerFile = project(":common").file("src/main/resources/${rootProject.access_widener_version}.${modid}.aw")
if (accessWidenerFile.exists()) {
delete accessWidenerFile
}
if (versionAccessWidenerFile.exists()) {
copy {
from versionAccessWidenerFile
into project(":common").file("src/main/resources/")
rename "${rootProject.access_widener_version}.${modid}.aw", "${modid}.accesswidener"
}
def text = accessWidenerFile.text
text += "\n# DO NOT EDIT\n# Generated by the build script. Edit ${versionAccessWidenerFile.name} instead!"
accessWidenerFile.text = text
} else {
versionAccessWidenerFile.createNewFile()
versionAccessWidenerFile.text = "accessWidener v2 named"
}
rootProject.ext.set("access_widener", "${rootProject.access_widener_version}.${modid}.aw")
}
// Defines the mixins
def defineMixins() {
def mixins = new ArrayList<String>()
def projects = new ArrayList<String>()
for (Project proj : rootProject.subprojects) {
projects.add(proj.name)
}
for (String proj : projects) {
for (File file : project(proj).file("src/main/resources/").listFiles()) {
if (file.getName().endsWith("mixin.json") || file.getName().endsWith("mixins.json")) {
mixins.add(file.getName())
}
}
}
rootProject.ext.set("mixins", mixins)
}