forked from AztechMC/Modern-Industrialization
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
512 lines (458 loc) · 16.3 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
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
plugins {
id 'java-library'
id 'eclipse'
id 'idea'
id 'maven-publish'
id 'net.neoforged.gradle.userdev' version '7.0.105'
id 'com.diffplug.spotless' version '5.14.0'
id 'com.matthewprenger.cursegradle' version '1.4.0'
id "com.modrinth.minotaur" version "2.+"
}
version = System.getenv("MI_VERSION")
? System.getenv("MI_VERSION")
: "0.0.0-local"
group = "aztech"
base {
archivesName = "Modern-Industrialization"
}
logger.lifecycle("Modern Industrialization version ${version}")
sourceCompatibility = JavaVersion.VERSION_21
targetCompatibility = JavaVersion.VERSION_21
java {
// toolchain {
// languageVersion = JavaLanguageVersion.of(21)
// vendor = JvmVendorSpec.MICROSOFT //JvmVendorSpec.matching("jetbrains")
// }
withSourcesJar()
}
repositories {
// for KJS
maven {
url "https://www.cursemaven.com"
content {
includeGroup "curse.maven"
}
}
// for Patchouli
maven {
url 'https://maven.blamejared.com'
}
// for AE2 and JEI
maven {
name "Modmaven"
url "https://modmaven.dev"
content {
includeGroup "appeng"
includeGroup "dev.technici4n"
includeGroup "mezz.jei"
}
}
maven {
url "https://maven.shedaniel.me"
content {
includeGroup "me.sargunvohra.mcmods"
includeGroup "me.shedaniel.cloth"
includeGroup "me.shedaniel"
includeGroup "dev.architectury"
}
}
maven {
url "https://maven.terraformersmc.com"
content {
includeGroup "com.terraformersmc"
includeGroup "dev.emi"
}
}
maven {
name 'Jitpack for MI'
url 'https://jitpack.io'
content {
includeGroup "com.github.KubeJS-Mods"
includeGroup "com.github.GabrielOlvH"
/* For Magna */
includeGroup "com.github.Draylar.omega-config"
/* For KubeJS */
includeGroup "com.github.llamalad7.mixinextras"
}
}
// to build indrev
maven {
name = "CottonMC"
url = "https://server.bbkr.space/artifactory/libs-release"
content {
includeGroup "io.github.cottonmc"
}
}
maven {
name = "dblsaiko"
url = "https://maven.dblsaiko.net/"
}
maven {
name = "Technici4n"
url = "https://raw.githubusercontent.com/Technici4n/Technici4n-maven/master/"
content {
includeGroup "net.fabricmc.fabric-api"
includeGroup "dev.technici4n"
includeGroup "dev.latvian.mods"
}
}
maven {
url "https://maven.saps.dev/minecraft"
content {
includeGroup "dev.latvian.mods"
includeGroup "dev.ftb.mods"
}
}
maven {
url "https://maven.ftb.dev/snapshots"
content {
includeGroup "dev.ftb.mods"
}
}
maven {
url "https://maven.parchmentmc.net/"
content {
includeGroup "org.parchmentmc.data"
}
}
// for AE2
maven {
name = "Modmaven"
url = uri("https://modmaven.dev/")
content {
includeGroup("appeng")
}
}
// For the "No Indium?" mod
maven {
url = 'https://maven.cafeteria.dev/releases/'
content {
includeGroup "me.luligabi"
}
}
// For FTBTeams/FTBQuests
maven {
url "https://maven.saps.dev/minecraft"
content {
includeGroup "dev.latvian.mods"
includeGroup "dev.ftb.mods"
}
}
maven {
url "https://maven.teamresourceful.com/repository/maven-public/"
content {
includeGroup "com.teamresourceful"
includeGroup "com.teamresourceful.resourcefullib"
includeGroup "earth.terrarium.argonauts"
includeGroup "earth.terrarium.athena"
}
}
maven { // TODO remove
name 'Maven for PR #794' // https://github.com/neoforged/NeoForge/pull/794
url 'https://prmaven.neoforged.net/NeoForge/pr794'
content {
includeModule('net.neoforged', 'testframework')
includeModule('net.neoforged', 'neoforge')
}
}
mavenLocal()
}
sourceSets {
main {
java {
srcDir "src/main"
}
resources {
srcDir "src/generated/resources"
}
runs {
modIdentifier "modern_industrialization"
}
}
client {
runs {
modIdentifier "modern_industrialization"
}
compileClasspath += sourceSets.main.compileClasspath
runtimeClasspath += sourceSets.main.runtimeClasspath
compileClasspath += sourceSets.main.output
runtimeClasspath += sourceSets.main.output
}
}
dependencies {
implementation "net.neoforged:neoforge:${project.neo_version}"
api jarJar("dev.technici4n:GrandPower:${project.grandpower_version}") {
jarJar.ranged(it, "[$project.grandpower_version,)")
}
if (project.runtime_itemlist_mod == "jei") {
implementation "mezz.jei:jei-${project.jei_minecraft_version}-neoforge:${project.jei_version}"
} else {
compileOnly "mezz.jei:jei-${project.jei_minecraft_version}-neoforge:${project.jei_version}"
}
if (project.runtime_itemlist_mod == "rei") {
implementation "me.shedaniel:RoughlyEnoughItems-neoforge:${project.rei_version}"
} else {
compileOnly "me.shedaniel:RoughlyEnoughItems-neoforge:${project.rei_version}"
}
compileOnly "me.shedaniel:REIPluginCompatibilities-forge-annotations:${project.rei_annotations_version}"
if (project.runtime_itemlist_mod == "emi") {
implementation "dev.emi:emi-neoforge:${project.emi_version}+${project.emi_minecraft_version}"
// Add JEI so that we can use EMI's builtin compat layer
runtimeOnly "mezz.jei:jei-${project.jei_minecraft_version}-neoforge:${project.jei_version}"
} else {
compileOnly "dev.emi:emi-neoforge:${project.emi_version}+${project.emi_minecraft_version}"
}
if (!(project.runtime_itemlist_mod in ["jei", "rei", "emi", "none"])) {
throw new GradleException("Invalid runtime_itemlist_mod value: " + project.runtime_itemlist_mod)
}
compileOnly "vazkii.patchouli:Patchouli:${project.patchouli_version}:api"
runtimeOnly "vazkii.patchouli:Patchouli:${project.patchouli_version}"
jarJar("vazkii.patchouli:Patchouli:${project.patchouli_version}") {
jarJar.ranged(it, "[$project.patchouli_version,)")
}
implementation("me.shedaniel.cloth:cloth-config-neoforge:${project.cloth_config_version}")
compileOnly "curse.maven:jade-324717:${project.jade_file_id}"
// modImplementation("dev.latvian.mods:kubejs-fabric:${project.kubejs_version}") {
// exclude(group: "net.fabricmc.fabric-api")
// }
implementation "appeng:appliedenergistics2-neoforge:${project.ae2_version}"
compileOnly "earth.terrarium.argonauts:argonauts-neoforge-${project.argonauts_minecraft_version}:${project.argonauts_version}"
compileOnly "earth.terrarium.athena:athena-neoforge-${project.athena_minecraft_version}:${project.athena_version}"
compileOnly "dev.ftb.mods:ftb-quests-neoforge:${project.ftb_quests_version}"
compileOnly "dev.ftb.mods:ftb-teams-neoforge:${project.ftb_teams_version}"
}
minecraft.accessTransformers.file file("src/main/resources/META-INF/accesstransformer.cfg")
runs {
// applies to all the run configs below
configureEach {
// Recommended logging data for a userdev environment
// The markers can be added/remove as needed separated by commas.
// "SCAN": For mods scan.
// "REGISTRIES": For firing of registry events.
// "REGISTRYDUMP": For getting the contents of all registries.
systemProperty 'forge.logging.markers', 'REGISTRIES'
// Recommended logging level for the console
// You can set various levels here.
// Please read: https://stackoverflow.com/questions/2031163/when-to-use-the-different-log-levels
systemProperty 'forge.logging.console.level', 'debug'
modSource project.sourceSets.main
modSource project.sourceSets.client
}
client {
// Comma-separated list of namespaces to load gametests from. Empty = all namespaces.
systemProperty 'forge.enabledGameTestNamespaces', "modern_industrialization"
}
server {
systemProperty 'forge.enabledGameTestNamespaces', "modern_industrialization"
programArgument '--nogui'
}
// This run config launches GameTestServer and runs all registered gametests, then exits.
// By default, the server will crash when no gametests are provided.
// The gametest system is also enabled by default for other run configs under the /test command.
gameTestServer {
systemProperty 'forge.enabledGameTestNamespaces', "modern_industrialization"
}
data {
// example of overriding the workingDirectory set in configureEach above, uncomment if you want to use it
// workingDirectory project.file('run-data')
// Specify the modid for data generation, where to output the resulting resource, and where to look for existing resources.
programArguments.addAll '--mod', "modern_industrialization", '--all', '--output', file('src/generated/resources/').getAbsolutePath(), '--existing', file('src/main/resources/').getAbsolutePath()
}
autotestServer {
configure 'server'
systemProperty 'modern_industrialization.autoTest', 'true'
}
}
processResources {
var replaceProperties = [
neo_version: neo_version,
neo_version_range: neo_version_range,
mod_version: version,
grandpower_version_range: grandpower_version_range,
ae2_version_range: ae2_version_range,
]
inputs.properties replaceProperties
filesMatching(['META-INF/neoforge.mods.toml', 'pack.mcmeta']) {
expand replaceProperties + [project: project]
}
}
//loom {
// accessWidenerPath = file("src/main/resources/modern_industrialization.accesswidener")
// mods {
// moderndynamics {
// sourceSet sourceSets.main
// sourceSet sourceSets.client
// }
// }
// runs {
// autoTestServer {
// server()
// name = "Autotest Server"
// vmArg "-Dmodern_industrialization.autoTest"
//
// ideConfigGenerated = true
// }
// datagenClient {
// client()
// name "Data Generation"
// vmArg "-Dfabric-api.datagen"
// vmArg "-Dfabric-api.datagen.modid=modern_industrialization"
// vmArg "-Dfabric-api.datagen.output-dir=${file("src/generated/resources")}"
// vmArg "-Dfabric-api.datagen.strict-validation=true"
//
// ideConfigGenerated = true
// runDir "build/datagen"
// source sourceSets.client
// }
// }
//}
tasks.withType(JavaCompile).configureEach {
// ensure that the encoding is set to UTF-8, no matter what the system default is
// this fixes some edge cases with special characters not displaying correctly
// see http://yodaconditions.net/blog/fix-for-java-file-encoding-problems-with-gradle.html
// If Javadoc is generated, this must be specified in that task too.
it.options.encoding = "UTF-8"
}
// Dirty hack to fix the absence of a toolchain. Blame Azercoco!
tasks.withType(net.neoforged.gradle.neoform.runtime.tasks.RecompileSourceJar).configureEach {
it.javaCompiler.set(project.extensions.getByType(JavaToolchainService.class).compilerFor {})
}
jar {
from "LICENSE"
from sourceSets.client.output
}
tasks.named("jarJar") {
from "LICENSE"
from sourceSets.client.output
}
// configure the maven publication
publishing {
publications {
mavenJava(MavenPublication) {
from components.java
}
}
// select the repositories you want to publish to
repositories {
maven {
credentials {
username = System.getenv("MODMAVEN_USER")
password = System.getenv("MODMAVEN_PASSWORD")
}
name = "modmaven"
url = "https://modmaven.dev/artifactory/local-releases/"
}
}
}
spotless {
format 'misc', {
target '*.gradle', '*.md', '.gitignore'
trimTrailingWhitespace()
indentWithSpaces()
endWithNewline()
}
java {
importOrder()
removeUnusedImports()
eclipse().configFile('eclipse-format.xml')
indentWithSpaces()
endWithNewline()
licenseHeaderFile 'LICENSE.java'
}
format 'json', {
target 'src/main/**/lang/*.json'
addStep(JsonOrderStep.create())
}
}
import com.diffplug.spotless.FormatterFunc
import com.diffplug.spotless.FormatterStep
import com.google.gson.Gson
import com.google.gson.GsonBuilder
final class JsonOrderStep {
private JsonOrderStep() {}
private static final Gson GSON = new GsonBuilder().disableHtmlEscaping().setLenient().setPrettyPrinting().create()
static FormatterStep create() {
return FormatterStep.create(
'jsonOrderStep',
new State(),
{
new FormatterFunc() {
String apply(String input) {
TreeMap<String, Object> jsonMap = GSON.fromJson(input, TreeMap.class)
String sortedJson = GSON.toJson(jsonMap)
String prettyPrinted = sortedJson.replace('\\u0027', '\'')
return prettyPrinted + "\n"
}
}
},
)
}
private static final class State implements Serializable {
private static final long serialVersionUID = 1L
private final int formatVersion = 1
}
}
def releaseChannel = "release"
def changelog = "Please visit our github repository for a changelog: https://github.com/AztechMC/Modern-Industrialization/releases."
if (version.toLowerCase().contains("alpha")) {
releaseChannel = "alpha"
changelog = "THIS IS AN ALPHA RELEASE, MAKE A BACKUP BEFORE INSTALLING AND FREQUENTLY WHILE PLAYING, AND PLEASE REPORT ANY ISSUE YOU MAY FIND ON OUR ISSUE TRACKER.\n\n" + changelog
} else if (version.toLowerCase().contains("beta")) {
releaseChannel = "beta"
changelog = "This is a beta release. It is expected to be mostly stable, but in any case please report any issue you may find.\n\n" + changelog
}
// Publishing
if (System.getenv("CURSEFORGE_API_KEY") && !version.endsWith("-SNAPSHOT")) {
curseforge {
apiKey = System.getenv().get("CURSEFORGE_API_KEY")
project {
id = project.curseforge_project
releaseType = releaseChannel
changelogType = "markdown"
delegate.changelog = changelog
addGameVersion "1.20.4"
addGameVersion "NeoForge"
addGameVersion "Java 21"
relations {
requiredDependency "cloth-config"
optionalDependency "wthit"
optionalDependency "emi"
optionalDependency "jei"
optionalDependency "roughly-enough-items"
embeddedLibrary "grandpower"
embeddedLibrary "patchouli"
}
mainArtifact(tasks.named("jarJar").flatMap { it.archiveFile }) {
displayName = "Modern Industrialization v${version}"
}
}
options {
forgeGradleIntegration = false
}
afterEvaluate {
tasks.getByName("curseforge${project.curseforge_project}").dependsOn tasks.jarJar
}
}
}
modrinth {
token = System.getenv("MODRINTH_API_KEY")
projectId = project.modrinth_project
versionNumber = version
versionName = "Modern Industrialization v${version}"
delegate.changelog = changelog
versionType = releaseChannel
uploadFile = tasks.jarJar
gameVersions = ["1.20.4"]
loaders = ["neoforge"]
dependencies {
required.project "cloth-config"
optional.project "wthit"
optional.project "emi"
optional.project "jei"
optional.project "rei"
embedded.project "patchouli"
}
}
tasks.modrinth.onlyIf {
System.getenv("MODRINTH_API_KEY") && !version.endsWith("-SNAPSHOT")
}