-
Notifications
You must be signed in to change notification settings - Fork 4
/
build.gradle
473 lines (386 loc) · 15.5 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
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
import com.hypherionmc.modpublisher.properties.ModLoader
import java.util.function.Consumer
plugins {
id 'eclipse'
id 'maven-publish'
id 'net.neoforged.gradle' version '[6.0.18,6.2)'
id 'org.spongepowered.mixin' version '0.7.+'
id 'org.parchmentmc.librarian.forgegradle' version '1.+'
id "com.modrinth.minotaur" version "2.+"
id "com.hypherionmc.modutils.modpublisher" version "2.+"
}
version = getVersionString()
group = 'com.enderio'
base {
archivesName = "EnderIOUnofficial-${minecraft_version}"
}
println("Building Ender IO version ${version}")
println("Release type: ${getReleaseType()}")
java {
toolchain {
languageVersion = JavaLanguageVersion.of(17)
if (System.getProperty('idea.active')) {
vendor = JvmVendorSpec.JETBRAINS
}
}
withSourcesJar()
}
// List of all subsets. This is used for dividing the mod into logical components.
// TODO: 1.19: Tidy the divisions and what goes where.
def subsets = [
'conduits',
'machines',
'armory'
]
sourceSets {
api
core {
compileClasspath += sourceSets.api.output
}
main {
compileClasspath += sourceSets.api.output
compileClasspath += sourceSets.core.output
ext.refMap = "mixins.enderio.refmap.json"
resources { srcDir 'src/generated/resources' }
}
}
// Configure the API source set.
configurations {
apiImplementation.extendsFrom(implementation)
apiCompileOnly.extendsFrom(compileOnly)
apiRuntimeOnly.extendsFrom(runtimeOnly)
coreImplementation.extendsFrom(implementation)
coreCompileOnly.extendsFrom(compileOnly)
coreRuntimeOnly.extendsFrom(runtimeOnly)
}
// Add all subset source sets.
for (String set : subsets) {
setupSourceSet(set)
}
minecraft {
mappings channel: mappings_channel, version: mappings_version
accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg')
runs {
configureEach {
property 'forge.logging.markers', 'REGISTRIES'
property 'forge.logging.console.level', 'debug'
property 'forge.enabledGameTestNamespaces', 'enderio'
// Enables better hot reloading if using the JetBrains Runtime
if (System.getProperty('idea.active')) {
jvmArgs '-XX:+AllowEnhancedClassRedefinition', '-XX:+IgnoreUnrecognizedVMOptions', '-XX:+AllowRedefinitionToAddDeleteMethods'
}
mods {
enderio {
source sourceSets.api
source sourceSets.core
source sourceSets.main
for (String set : subsets) {
source sourceSets.getByName(set)
}
}
}
}
client {
workingDirectory project.file('run/client')
}
clientRandom {
parent runs.client
args '--username', 'Dev####'
}
server {
workingDirectory project.file('run/server')
}
data {
workingDirectory project.file('run/data')
// Specify the modid for data generation, where to output the resulting resource, and where to look for existing resources.
args '--mod', 'enderio', '--server', '--client', '--output', file('src/generated/resources/'),
'--existing', file('src/main/resources/'),
'--existing', file('src/machines/resources/'),
'--existing', file('src/conduits/resources/'),
'--existing', file('src/armory/resources/')
}
dataProd {
parent runs.data
args '--all'
}
}
}
def replaceProperties = [
version : version, mcversion: minecraft_version_range,
forge_version : forge_version_range,
loader_version: loader_version_range]
processResources {
inputs.properties replaceProperties
replaceProperties.put 'project', project
filesMatching('META-INF/mods.toml') {
expand replaceProperties
}
}
// pupnewfster helpers for exclusive repos
void exclusiveRepo(RepositoryHandler handler, String url, String... groups) {
exclusiveRepo(handler, url, filter -> {
for (def group : groups) {
filter.includeGroup(group)
}
})
}
//Note: This cannot be static so that fg.repository can be properly accessed
@SuppressWarnings('GrMethodMayBeStatic')
void exclusiveRepo(RepositoryHandler handler, String url, Consumer<InclusiveRepositoryContentDescriptor> filterSetup) {
handler.exclusiveContent {
it.forRepositories(handler.maven {
setUrl(url)
}, fg.repository)//Add FG's repo so we make sure we are able to then find the mapped deps
it.filter { f -> filterSetup.accept(f) }
}
}
repositories { RepositoryHandler handler ->
exclusiveRepo(handler, 'https://maven.tterrag.com/', 'com.tterrag.registrate', 'com.jozufozu.flywheel')
exclusiveRepo(handler, 'https://modmaven.dev/', 'mcjty.theoneprobe', 'appeng')
exclusiveRepo(handler, 'https://cursemaven.com', 'curse.maven')
exclusiveRepo(handler, 'https://maven.blamejared.com', 'mezz.jei', 'vazkii.patchouli', 'net.darkhax.bookshelf', 'net.darkhax.enchdesc', 'com.almostreliable.mods')
exclusiveRepo(handler, 'https://dogforce-games.com/maven', 'dev.gigaherz.graph')
exclusiveRepo(handler, 'https://api.modrinth.com/maven', 'maven.modrinth')
mavenLocal()
}
jarJar.enable()
dependencies {
// Forge
minecraft "net.neoforged:forge:${minecraft_version}-${forge_version}"
// Registrate
implementation fg.deobf("com.tterrag.registrate:Registrate:MC1.20-${registrate_version}")
jarJar(group: 'com.tterrag.registrate', name: 'Registrate', version: "${registrate_version_range}")
// GraphLib
implementation implementation(fg.deobf("dev.gigaherz.graph:GraphLib3:${graphlib_version}"))
jarJar(group: 'dev.gigaherz.graph', name: 'GraphLib3', version: "${graphlib_version_range}")
// Mixin annotations
annotationProcessor 'org.spongepowered:mixin:0.8.5:processor'
// JEI
compileOnly fg.deobf("mezz.jei:jei-${minecraft_version}-common-api:${jei_version}")
compileOnly fg.deobf("mezz.jei:jei-${minecraft_version}-forge-api:${jei_version}")
runtimeOnly fg.deobf("mezz.jei:jei-${minecraft_version}-forge:${jei_version}")
//RFTOOLS
runtimeOnly fg.deobf("maven.modrinth:rftools-power:f430rHkA")
runtimeOnly fg.deobf("maven.modrinth:mcjtylib:3LlgyvSh")
runtimeOnly fg.deobf("maven.modrinth:rftools-base:Uu1IkVMH")
runtimeOnly fg.deobf("maven.modrinth:spark:Yp6s4wsw")
//Athena ctm
runtimeOnly fg.deobf("maven.modrinth:athena-ctm:X6GdUrpW")
// AE2
compileOnly "appeng:appliedenergistics2-forge:${ae2_version}:api"
runtimeOnly fg.deobf("appeng:appliedenergistics2-forge:${ae2_version}")
// Enchantment descriptions
runtimeOnly fg.deobf("net.darkhax.bookshelf:Bookshelf-Forge-${minecraft_version}:${bookshelf_version}")
runtimeOnly fg.deobf("net.darkhax.enchdesc:EnchantmentDescriptions-Forge-${minecraft_version}:${ench_desc_version}")
// Jade
runtimeOnly fg.deobf("curse.maven:jade-324717:${jade_cf_id}")
//fluxnetworks
runtimeOnly fg.deobf("curse.maven:fluxnetworks-248020:4651164")
//Flywheel
compileOnly fg.deobf("com.jozufozu.flywheel:flywheel-forge-1.20.1:0.6.9-5") // REMOVE When crash is fixed
// Almost Unified
compileOnly fg.deobf("com.almostreliable.mods:almostunified-forge:${minecraft_version}-${almostunified_version}")
// Patchouli
// compileOnly fg.deobf("vazkii.patchouli:Patchouli:${patchouli_version}:api")
// runtimeOnly fg.deobf("vazkii.patchouli:Patchouli:${patchouli_version}")
// Jetbrains annotations
compileOnly 'org.jetbrains:annotations:23.0.0'
}
// MixinGradle Settings
mixin {
add sourceSets.main, "mixins.enderio.refmap.json"
config "mixins.enderio.json"
}
reobf.create('jarJar')
// Example for how to get properties into the manifest for reading at runtime.
jar {
archiveClassifier = "partial"
manifest {
attributes([
"Specification-Title" : project.name,
"Specification-Vendor" : "SleepyTrousers",
"Specification-Version" : "1",
"Implementation-Title" : project.name,
"Implementation-Version" : project.version,
"Implementation-Vendor" : "SleepyTrousers",
'Implementation-Commit' : 'git rev-parse HEAD'.execute().text.trim(),
"Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ"),
"MixinConfigs" : "enderio.mixins.json"
])
}
// Add all other source sets
from sourceSets.api.output
from sourceSets.core.output
for (String set : subsets) {
from sourceSets.getByName(set).output
}
finalizedBy('reobfJar')
}
tasks.register('apiJar', Jar) {
group = 'build'
archiveClassifier = 'api'
from sourceSets.api.output
}
build.dependsOn apiJar
// Add other source sets to jarJar
tasks.named('jarJar') {
archiveClassifier = ""
from sourceSets.api.output
from sourceSets.core.output
for (String set : subsets) {
from sourceSets.getByName(set).output
}
finalizedBy('reobfJarJar')
}
build.dependsOn tasks.jarJar
tasks.withType(JavaCompile).configureEach {
options.encoding = 'UTF-8' // Use the UTF-8 charset for Java compilation
}
// publisher task hackery because it wont run the tasks!
tasks.publishCurseforge {
dependsOn(tasks.sourcesJar)
dependsOn(tasks.apiJar)
}
publisher {
apiKeys {
curseforge System.getenv("CURSEFORGE_TOKEN")
}
setDebug(System.getenv("PUBLISH") != "true" || System.getenv("CHANGELOG") == null)
setCurseID(curseforge_projectId)
setChangelog(System.getenv("CHANGELOG"))
setVersionType(getReleaseType())
setVersion("${getVersionString()}")
setDisplayName("[1.20.1] Ender IO Unofficial - ${getVersionString()}")
setGameVersions("1.20.1")
setGameVersions(["${minecraft_version}"])
setLoaders(ModLoader.FORGE, ModLoader.NEOFORGE)
setJavaVersions([JavaVersion.VERSION_17])
setDisableEmptyJarCheck(false)
setArtifact(tasks.jarJar)
addAdditionalFile {
artifact tasks.sourcesJar
displayName "EIOU Sources - ${getVersionString()}"
changelog "# Do not download this, this is only for developers"
}
addAdditionalFile {
artifact tasks.apiJar
displayName "EIOU API - ${getVersionString()}"
changelog "# Do not download this, this is only for developers"
}
curseDepends {
optional "jei", "athena", "applied-energistics-2"
}
}
// TODO: temp disable maven publication
/*
publishing {
publications {
maven(MavenPublication) {
groupId = 'com.enderio'
artifactId = 'EnderIO'
version = "${minecraft_version}-${version}"
artifact jar
artifact sourcesJar
artifact apiJar
pom {
name = 'Ender IO'
description = 'Ender IO is a full-featured tech mod. It has armor, tools, weapons, machines, conduits, inventory management, mobs, etc.'
url = 'https://github.com/Monifactory/EnderIO'
licenses {
license {
name = 'Unlicense'
url = 'https://github.com/SleepyTrousers/EnderIO-Rewrite/blob/dev/1.18.x/LICENSE.txt'
}
}
scm {
url = 'https://github.com/Monifactory/EnderIO.git'
}
}
}
}
repositories {
if (System.getenv("RVR_MAVEN_USER") != null) {
maven {
name = "Rover656"
url = "https://maven.rover656.dev/releases"
credentials {
username = System.getenv("RVR_MAVEN_USER")
password = System.getenv("RVR_MAVEN_PASSWORD")
}
}
}
}
}
*/
// ============
// Utilities
// ============
// * enderio-1.19.1-6.0.1-alpha.jar :: release version 6.0.1-alpha for mc 1.19.1
// * enderio-1.19.1-nightly-4 :: nightly build no. 4 for mc 1.19.1
// * enderio-1.19.1-dev-c91c8ee6e :: dev (local) build for commit c91c8ee6e
String getVersionString() {
def build_server = System.getenv('CI') != null || System.getenv('BUILD_NUMBER') != null
if (System.getenv('BUILD_VERSION') != null) {
def version_number = System.getenv('BUILD_VERSION')
if (version_number.startsWith("v")) {
version_number = version_number.substring(1)
}
return "${version_number}"
}
if (System.getenv('NIGHTLY') != null) {
def version_patch_lc = '0'
if (System.getenv('BUILD_NUMBER') != null) {
version_patch_lc = System.getenv('BUILD_NUMBER')
}
return "${mod_version_series}-nightly-${version_patch_lc}"
}
def version_hash = ''
def branch_name = ''
if (!build_server) {
try {
version_hash = "-" + "git rev-parse --short HEAD".execute().text.trim()
} catch (ignored) {
}
try {
branch_name = "git rev-parse --abbrev-ref HEAD".execute().text.trim()
branch_name = "-" + branch_name.substring(branch_name.lastIndexOf('/') + 1)
} catch (ignored) {
}
}
return "${mod_version_series}-dev${branch_name}${version_hash}"
}
String getReleaseType() {
// If we're doing a proper build
if (System.getenv('BUILD_VERSION') != null) {
def version_string = System.getenv('BUILD_VERSION')
if (version_string.toLowerCase(Locale.ROOT).contains("alpha")) {
return 'alpha'
} else if (version_string.toLowerCase(Locale.ROOT).contains("beta")) {
return 'beta'
}
return 'release'
}
return null
}
// Thanks to Mekanism for the base implementations here.
// Create and configure a new module source set.
def setupSourceSet(String name) {
def sourceSet = sourceSets.create(name)
// Add api and main modules.
sourceSet.compileClasspath += sourceSets.api.output
sourceSet.compileClasspath += sourceSets.main.output
sourceSet.compileClasspath += sourceSets.core.output
// Extend configurations
setupExtraSourceSets(sourceSet)
}
// Thanks again to Mekanism for this stuff.
def setupExtraSourceSets(SourceSet base) {
// Setup and extend configurations for alternate modules. First by making the implementation, compileOnly, runtimeOnly equivalents
// for those modules extend the main ones
def baseImplementation = project.configurations.maybeCreate(base.getTaskName(null, "implementation"))
def baseCompileOnly = project.configurations.maybeCreate(base.getTaskName(null, "compileOnly"))
def baseRuntimeOnly = project.configurations.maybeCreate(base.getTaskName(null, "runtimeOnly"))
baseImplementation.extendsFrom(project.configurations.getByName("implementation"))
baseCompileOnly.extendsFrom(project.configurations.getByName("compileOnly"))
baseRuntimeOnly.extendsFrom(project.configurations.getByName("runtimeOnly"))
}