forked from AppliedEnergistics/Applied-Energistics-2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle
659 lines (591 loc) · 21.2 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
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2015, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
plugins {
id "fabric-loom"
id "maven-publish"
// id "com.diffplug.spotless"
id "io.github.juuxel.loom-quiltflower"
id "io.github.goooler.shadow"
id "de.undercouch.download"
}
sourceSets {
portaforgy
main {
compileClasspath += sourceSets.portaforgy.output
runtimeClasspath += sourceSets.portaforgy.output
java {
srcDir 'src/main/flatbuffers/generated'
}
resources {
srcDir 'src/generated/resources'
}
}
test {
compileClasspath += sourceSets.portaforgy.output
runtimeClasspath += sourceSets.portaforgy.output
}
buildtools
}
configurations {
shaded {
transitive = false
}
portaforgyImplementation.extendsFrom(compileClasspath)
buildtoolsImplementation.extendsFrom(compileClasspath)
internal {
visible = false
canBeConsumed = false
canBeResolved = false
}
configurations.compileClasspath.extendsFrom(internal)
configurations.runtimeClasspath.extendsFrom(internal)
configurations.testCompileClasspath.extendsFrom(internal)
configurations.testRuntimeClasspath.extendsFrom(internal)
}
dependencies {
// To be copied into the jar file
shaded project(path: ':libs:markdown', configuration: "archives")
shaded "io.methvin:directory-watcher:${directory_watcher_version}"
shaded "org.yaml:snakeyaml:${snakeyaml_version}"
shaded "com.google.flatbuffers:flatbuffers-java:${flatbuffers_version}"
internal project(':libs:markdown')
// Do not inherit any transitive dependencies here since we rely on those dependencies being
// present in Minecrafts own dependencies already.
internal("io.methvin:directory-watcher:${directory_watcher_version}") {
transitive = false
}
internal("org.yaml:snakeyaml:${snakeyaml_version}") {
transitive = false
}
internal("com.google.flatbuffers:flatbuffers-java:${flatbuffers_version}") {
transitive = false
}
// Used for the guide export
internal("org.bytedeco:ffmpeg-platform:6.0-1.5.9")
// To change the versions see the gradle.properties file
minecraft "com.mojang:minecraft:${project.minecraft_version}"
mappings loom.layered() {
officialMojangMappings()
parchment("org.parchmentmc.data:parchment-${rootProject.minecraft_version}:${parchment_mappings_version}@zip")
}
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"
testImplementation "net.fabricmc:fabric-loader-junit:${project.loader_version}"
// Architectury API
modImplementation("dev.architectury:architectury-fabric:${project.architectury_api_version}") {
exclude group: "net.fabricmc"
exclude group: "net.fabricmc.fabric-api"
}
// Always depend on the REI API to compile
modCompileOnly("me.shedaniel:RoughlyEnoughItems-api-fabric:${project.rei_version}") {
exclude group: "net.fabricmc"
exclude group: "net.fabricmc.fabric-api"
exclude group: "org.yaml" // snakeyaml
exclude group: "blue.endless" // jankson
}
modCompileOnly("me.shedaniel:RoughlyEnoughItems-default-plugin-fabric:${project.rei_version}") {
exclude group: "net.fabricmc"
exclude group: "net.fabricmc.fabric-api"
exclude group: "org.yaml" // snakeyaml
exclude group: "blue.endless" // jankson
}
if (project.runtime_itemlist_mod == "jei") {
modCompileOnly("me.shedaniel:RoughlyEnoughItems-fabric:${project.rei_version}") {
exclude group: "net.fabricmc"
exclude group: "net.fabricmc.fabric-api"
}
modLocalRuntime modCompileOnly("mezz.jei:jei-${jei_minecraft_version}-fabric:${jei_version}") {
exclude group: "mezz.jei"
}
} else if (project.runtime_itemlist_mod == "rei") {
modCompileOnly("mezz.jei:jei-${jei_minecraft_version}-fabric:${jei_version}") {
exclude group: "mezz.jei"
}
modLocalRuntime modCompileOnly("me.shedaniel:RoughlyEnoughItems-fabric:${project.rei_version}") {
exclude group: "net.fabricmc"
exclude group: "net.fabricmc.fabric-api"
}
} else {
modCompileOnly("me.shedaniel:RoughlyEnoughItems-fabric:${project.rei_version}") {
exclude group: "net.fabricmc"
exclude group: "net.fabricmc.fabric-api"
}
modCompileOnly("mezz.jei:jei-${jei_minecraft_version}-fabric:${jei_version}") {
exclude group: "mezz.jei"
}
}
modCompileOnly("mcp.mobius.waila:wthit-api:fabric-${project.wthit_version}") {
exclude group: "net.fabricmc"
exclude group: "net.fabricmc.fabric-api"
}
if (project.runtime_tooltip_mod == "wthit") {
modLocalRuntime("mcp.mobius.waila:wthit:fabric-${project.wthit_version}") {
exclude group: "net.fabricmc"
exclude group: "net.fabricmc.fabric-api"
}
}
modCompileOnly("curse.maven:jade-324717:${project.jade_file_id}") {
exclude group: "net.fabricmc"
exclude group: "net.fabricmc.fabric-api"
}
if (project.runtime_tooltip_mod == "jade") {
modLocalRuntime("curse.maven:jade-324717:${project.jade_file_id}") {
exclude group: "net.fabricmc"
exclude group: "net.fabricmc.fabric-api"
}
}
// Fabric API. This is technically optional, but you probably want it anyway.
modImplementation("net.fabricmc.fabric-api:fabric-api:${project.fabric_version}")
include modImplementation("teamreborn:energy:${project.tr_energy_version}") {
exclude group: "net.fabricmc"
exclude group: "net.fabricmc.fabric-api"
}
// TODO 1.20
// Include No Indium? https://github.com/Luligabi1/NoIndium
//include "me.luligabi:NoIndium:${project.no_indium_version}"
// unit test dependencies
testImplementation(platform("org.junit:junit-bom:${project.junit_version}"))
testImplementation("org.junit.jupiter:junit-jupiter-api")
testImplementation("org.junit.jupiter:junit-jupiter-params")
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine")
testImplementation("org.junit.platform:junit-platform-launcher")
testImplementation("org.assertj:assertj-core:3.19.0")
testImplementation("com.google.guava:guava-testlib:21.0")
testImplementation("org.mockito:mockito-junit-jupiter:5.3.1")
compileOnly 'org.apache.commons:commons-configuration2:2.9.0'
}
fabricApi {
configureDataGeneration() {
client = true
}
}
archivesBaseName = artifact_basename
allprojects {
group = artifact_group
java {
toolchain {
languageVersion = JavaLanguageVersion.of(21)
}
}
repositories {
mavenLocal()
mavenCentral()
maven {
url "https://maven.shedaniel.me/"
content {
includeGroup "me.shedaniel"
includeGroup "me.shedaniel.cloth"
includeGroup "dev.architectury"
}
}
maven {
url "https://maven.bai.lol"
content {
includeGroup "mcp.mobius.waila"
includeGroup "lol.bai"
}
}
maven {
url "https://maven.parchmentmc.net/"
content {
includeGroup "org.parchmentmc.data"
}
}
// For the "No Indium?" mod
maven {
url = 'https://maven.cafeteria.dev/releases/'
content {
includeGroup "me.luligabi"
}
}
maven {
name 'modmaven'
url "https://modmaven.dev/"
content {
includeGroup "mezz.jei"
}
}
maven {
name 'cursemaven'
url "https://www.cursemaven.com"
content {
includeGroup "curse.maven"
}
}
maven {
url "https://maven.blamejared.com"
content {
includeGroup "vazkii.patchouli"
}
}
}
// ensure everything uses UTF-8 and not some random codepage chosen by gradle
compileJava.options.encoding = 'UTF-8'
tasks.withType(JavaCompile) {
options.encoding = 'UTF-8'
options.deprecation = false
options.compilerArgs << "-Xmaxerrs" << "9999"
}
}
///////////////////
// Version Number
version = version_major + "." + version_minor + "." + version_patch
ext.pr = System.getenv('PR_NUMBER') ?: ""
if (ext.pr) {
version = version + "+pr." + ext.pr
}
ext.branch = System.getenv('BRANCH') ?: ""
if (ext.branch) {
version = version + "+branch." + ext.branch
}
ext.tag = System.getenv('TAG') ?: ""
if (ext.tag) {
if (!ext.tag.startsWith("fabric/v")) {
throw new GradleException("Tags for the fabric version should start with fabric/: ${ext.tag}")
}
version = ext.tag.substring("fabric/v".length())
// Validate that the rest is a semver version
if (version ==~ /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$/) {
if (System.getenv("GITHUB_ENV")) {
def envFile = new File(System.getenv("GITHUB_ENV"))
envFile.append("VERSION=${version}")
}
} else {
throw new GradleException("Invalid semver: $version")
}
}
ext.isAlpha = project.version.contains("alpha")
ext.isBeta = project.version.contains("beta")
test {
useJUnitPlatform()
}
dependencies {
buildtoolsImplementation 'de.siegmar:fastcsv:2.1.0'
buildtoolsImplementation 'com.google.code.gson:gson:2.8.9'
}
////////////////////
// Forge/Minecraft
loom {
accessWidenerPath = file("src/main/resources/ae2.accesswidener")
runs {
client {
programArgs "--username", "AE2Dev"
property "appeng.tests", "true"
property 'appeng.version', project.version
property "guideDev.ae2guide.sources", file("guidebook").absolutePath
}
gametestWorld {
client()
programArgs "--username", "AE2Dev", "--quickPlaySingleplayer", "GametestWorld"
property "appeng.tests", "true"
property 'appeng.version', project.version
property "guideDev.ae2guide.sources", file("guidebook").absolutePath
}
guide {
client()
programArgs "--username", "AE2Dev"
property "appeng.tests", "true"
property 'appeng.version', project.version
property "guideDev.ae2guide.sources", file("guidebook").absolutePath
property "guideDev.ae2guide.startupPage", "ae2:index.md"
}
datagen {
client()
property "fabric-api.datagen"
property 'appeng.version', project.version
property "fabric-api.datagen.output-dir", file("src/generated/resources").absolutePath
property "appeng.datagen.existingData", file("src/main/resources").absolutePath
}
guideexport {
client()
property "appeng.runGuideExportAndExit", "true"
property 'appeng.version', project.version
property "appeng.guideExportFolder", file("$buildDir/guide").absolutePath
property "guideDev.ae2guide.sources", file("guidebook").absolutePath
}
// Use to run the tests
gametest {
server()
name "Game Test"
property "appeng.tests", "true"
vmArg "-Dfabric-api.gametest"
runDir "build/gametest"
source sourceSets.test
}
}
}
// For reproducible results, the world should be deleted before each run
task cleanGametestWorld(type: Delete) {
delete "build/gametest"
}
tasks.runGametest.dependsOn cleanGametestWorld
//////////////
// Artifacts
processResources {
exclude '.cache'
filesMatching("fabric.mod.json") {
expand "version": project.version
}
}
jar.enabled = false // Replaced by "shadowJar"
shadowJar {
finalizedBy 'remapJar'
from sourceSets.main.output.classesDirs
from sourceSets.main.output.resourcesDir
from('guidebook') {
into 'assets/ae2/ae2guide'
}
manifest {
attributes([
"Specification-Title" : "Applied Energistics 2",
"Specification-Vendor" : "TeamAppliedEnergistics",
"Specification-Version" : "${project.version}",
"Implementation-Title" : "${project.name}",
"Implementation-Version": "${project.version}",
"Implementation-Vendor" : "TeamAppliedEnergistics",
"MixinConfigs" : "ae2.mixins.json"
])
}
relocate "io.methvin", "appeng.shaded.methvin"
relocate "org.yaml.snakeyaml", "appeng.shaded.snakeyaml"
relocate "com.google.flatbuffers", "appeng.shaded.flatbuffers"
configurations = [project.configurations.shaded]
archiveClassifier = jar.archiveClassifier
destinationDirectory = jar.destinationDirectory
}
remapJar {
inputFile = shadowJar.archiveFile
}
def publicApiIncludePatterns = {
exclude "**/*Internal.*"
exclude "**/*Internal\$*.*"
include "appeng/api/**"
}
javadoc {
source = sourceSets.main.allJava
classpath = sourceSets.main.compileClasspath + sourceSets.main.output
options.addStringOption('Xdoclint:none', '-quiet')
options.encoding = 'UTF-8'
options.charSet = 'UTF-8'
}
javadoc publicApiIncludePatterns
task javadocJar(type: Jar, dependsOn: javadoc, group: "build") {
archiveClassifier = "javadoc"
from javadoc.destinationDir
}
// Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task
// if it is present.
// If you remove this task, sources will not be generated.
task sourcesJar(type: Jar) {
dependsOn(classes, runDatagen)
archiveClassifier = "sources"
from sourceSets.main.allSource
}
task apiJar(type: Jar, group: "build") {
archiveClassifier = "api"
// api jar ist just a development aid and serves as both a binary and source jar simultaneously
from sourceSets.main.output
from sourceSets.main.allJava
manifest {
attributes("Fabric-Loom-Remap": true)
}
}
apiJar publicApiIncludePatterns
artifacts {
archives javadocJar
archives sourcesJar
archives apiJar
}
//////////////////
// Maven publish
publishing {
if (!version.endsWith("-SNAPSHOT")) {
publications {
maven(MavenPublication) {
groupId = project.group
artifactId = 'appliedenergistics2-fabric'
version = project.version
// add all the jars that should be included when publishing to maven
artifact(remapJar) {
builtBy remapJar
}
artifact(sourcesJar) {
builtBy remapSourcesJar
}
artifact javadocJar
artifact apiJar
}
}
}
repositories {
maven {
name = "Local"
url = file("build/repo").toURI()
}
}
}
/////////////
// Spotless
//spotless {
//
// java {
// target 'src/*/java/appeng/**/*.java'
//
// endWithNewline()
// indentWithSpaces()
// removeUnusedImports()
// toggleOffOn()
// eclipse().configFile 'codeformat/codeformat.xml'
// importOrderFile 'codeformat/ae2.importorder'
//
// // courtesy of diffplug/spotless#240
// // https://github.com/diffplug/spotless/issues/240#issuecomment-385206606
// custom 'noWildcardImports', {
// it
// }
// bumpThisNumberIfACustomStepChanges(2)
// }
//
// format 'json', {
// target 'src/*/resources/**/*.json'
// targetExclude 'src/generated/resources/**'
// prettier().config(['parser': 'json'])
// }
//}
////////////////
// Crowdin
task uploadToCrowdin(type: JavaExec) {
classpath = sourceSets.buildtools.runtimeClasspath
mainClass = 'Crowdin'
args 'upload_source'
workingDir "."
}
task uploadTranslations(type: JavaExec) {
classpath = sourceSets.buildtools.runtimeClasspath
mainClass = 'Crowdin'
args 'upload_translations'
workingDir "."
}
task downloadFromCrowdin(type: JavaExec) {
classpath = sourceSets.buildtools.runtimeClasspath
mainClass = 'Crowdin'
args 'update_translations'
workingDir "."
}
////////////////
// IntelliJ Project Import
// The Mixin annotation process does not have an obfuscation source when running through the IntelliJ compiler,
// thus we have to prevent it from being activated as part of importing this Gradle project into IntelliJ.
if (System.getProperty("idea.sync.active") == "true") {
afterEvaluate {
tasks.withType(JavaCompile).all {
it.options.annotationProcessorPath = files()
}
}
}
// See https://github.com/AppliedEnergistics/Applied-Energistics-2/issues/5259
// Gradle module metadata contains mapped dependencies, making our artifacts unconsumable
tasks.withType(GenerateModuleMetadata) {
enabled = false
}
check.dependsOn tasks.register('validateResources', JavaExec) {
group = "verification"
classpath = sourceSets.buildtools.runtimeClasspath
mainClass = 'ValidateResourceIds'
workingDir "."
args "guidebook"
}
/**
* This task download the FlatBuffers compiler suitable for the current platform.
*/
tasks.register('downloadFlatbufferCompiler', Download) {
var os = System.getProperty("os.name").toLowerCase(Locale.ROOT)
var arch = System.getProperty("os.arch")
if (os.startsWith("windows")) {
src "https://github.com/google/flatbuffers/releases/download/v${flatbuffers_version}/Windows.flatc.binary.zip"
} else if (os.startsWith("mac")) {
if (arch == "aarch64") {
src "https://github.com/google/flatbuffers/releases/download/v${flatbuffers_version}/Mac.flatc.binary.zip"
} else if (arch == "amd64") {
src "https://github.com/google/flatbuffers/releases/download/v${flatbuffers_version}/MacIntel.flatc.binary.zip"
} else {
throw new GradleException("Unknown Mac architecture: $arch")
}
} else if (os.startsWith("linux")) {
src "https://github.com/google/flatbuffers/releases/download/v${flatbuffers_version}/Linux.flatc.binary.clang++-12.zip"
} else {
throw new GradleException("Unknown OS: $os")
}
onlyIfModified true
dest "${project.buildDir}/flatc.zip"
}
tasks.register('downloadAndUnzipFlatbufferCompiler', Copy) {
dependsOn downloadFlatbufferCompiler
from zipTree(downloadFlatbufferCompiler.dest)
into "${project.buildDir}/flatbuffers-bin"
}
/**
* Update the generated Java Code for our scene export schema.
* The code is checked in so this only needs to be run when the schema changes.
*/
tasks.register('updateFlatbufferSources', Exec) {
group 'build'
dependsOn downloadAndUnzipFlatbufferCompiler
workingDir project.projectDir
commandLine "${project.buildDir}/flatbuffers-bin/flatc",
"--gen-mutable",
"--java-package-prefix", "appeng.flatbuffers",
"--gen-generated",
"--java",
"-o",
"${project.projectDir}/src/main/flatbuffers/generated",
"${project.projectDir}/src/main/flatbuffers/scene.fbs"
doFirst {
file("${project.projectDir}/src/main/flatbuffers/generated").deleteDir()
}
doLast {
}
doLast {
// sadly flatc uses an outdated annotation
def folder = file("${project.projectDir}/src/main/flatbuffers/generated")
folder.eachFileRecurse(groovy.io.FileType.FILES) { file ->
String content = file.text
if (content.contains('@javax.annotation.Generated')) {
content = content.replace('@javax.annotation.Generated', '@javax.annotation.processing.Generated')
file.write(content)
}
}
}
}
/**
* Generate the TypeScript sources for our schema. The sources are manually copied
* over to the website repository.
*/
tasks.register('updateFlatbufferTypescriptSources', Exec) {
group 'build'
dependsOn downloadAndUnzipFlatbufferCompiler
workingDir project.projectDir
commandLine "${project.buildDir}/flatbuffers-bin/flatc",
"--ts-flat-files",
"--ts",
"-o",
"${project.buildDir}/scene-ts",
"${project.projectDir}/src/main/flatbuffers/scene.fbs"
doFirst {
file("${project.buildDir}/scene-ts").deleteDir()
}
}