-
-
Notifications
You must be signed in to change notification settings - Fork 74
/
Copy pathbuild.gradle
622 lines (537 loc) · 21.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
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
import net.darkhax.curseforgegradle.TaskPublishCurseForge
import java.text.SimpleDateFormat
plugins {
id "maven-publish"
id 'net.darkhax.curseforgegradle' version '1.1.16'
id 'org.jetbrains.changelog' version '1.2.1'
id "com.modrinth.minotaur" version "2.+"
id "org.jetbrains.kotlin.jvm" version "1.6.10"
id 'net.neoforged.gradle' version '[6.0.18,6.2)'
id 'org.spongepowered.mixin' version '0.7.+'
id "com.github.breadmoirai.github-release" version "2.5.2"
id 'checkstyle'
id 'java'
}
java {
toolchain {
languageVersion = JavaLanguageVersion.of(17)
}
withSourcesJar()
}
wrapper {
gradleVersion = '8.4'
distributionType = Wrapper.DistributionType.ALL
}
def isSnapshotVersion = project.hasProperty('teamcityBuild')
version = "${mod_version}" + (isSnapshotVersion ? "-SNAPSHOT" : "")
group = 'de.srendi.advancedperipherals'
def static getenv(path = ".env") {
def env = [:]
def file = new File(path)
if (file.exists()) {
file.eachLine { line ->
def (name, value) = line.tokenize("=")
if (value != null) {
env[name.trim()] = value.trim()
}
}
}
return env
}
def secretEnv = getenv()
def curseforgeKey = secretEnv["CURSEFORGE_KEY"] ?: System.getenv("CURSEFORGE_KEY") ?: ''
def modrinthKey = secretEnv["MODRINTH_KEY"] ?: System.getenv("MODRINTH_KEY")
def repositoryName = secretEnv["PUBLIC_REP_NAME"] ?: System.getenv("PUBLIC_REP_NAME")
def repositoryKey = secretEnv["PUBLIC_REP_KEY"] ?: System.getenv("PUBLIC_REP_KEY")
def githubKey = secretEnv["GITHUB_KEY"] ?: System.getenv("GITHUB_KEY")
// Include resources generated by data generators.
sourceSets {
main.resources {
srcDir 'src/generated/resources'
}
testMod {}
}
minecraft {
mappings channel: "${mappings_channel}", version: "${mappings_version}"
accessTransformer file('src/main/resources/META-INF/accesstransformer.cfg')
accessTransformer file('src/testMod/resources/META-INF/accesstransformer.cfg')
runs {
client {
workingDirectory project.file('run')
property 'forge.logging.markers', 'SCAN,REGISTRIES,REGISTRYDUMP'
property 'mixin.env.remapRefMap', 'true'
property 'mixin.env.refMapRemappingFile', "${buildDir}/createSrgToMcp/output.srg"
properties 'forge.logging.console.level': 'debug'
mods {
advancedperipherals {
source sourceSets.main
}
}
if (project.hasProperty('mc_uuid')) {
args '--uuid', project.getProperty('mc_uuid')
}
if (project.hasProperty('mc_username')) {
args '--username', project.getProperty('mc_username')
}
if (project.hasProperty('mc_accessToken')) {
args '--accessToken', project.getProperty('mc_accessToken')
}
}
server {
workingDirectory project.file('server')
property 'forge.logging.markers', 'SCAN,REGISTRIES,REGISTRYDUMP'
property 'mixin.env.remapRefMap', 'true'
property 'mixin.env.refMapRemappingFile', "${buildDir}/createSrgToMcp/output.srg"
property 'forge.logging.console.level', 'info'
mods {
advancedperipherals {
source sourceSets.main
}
}
}
data {
workingDirectory project.file('run')
property 'forge.logging.markers', 'SCAN,REGISTRIES,REGISTRYDUMP'
property 'mixin.env.remapRefMap', 'true'
property 'mixin.env.refMapRemappingFile', "${buildDir}/createSrgToMcp/output.srg"
property 'forge.logging.console.level', 'debug'
args '--mod', 'advancedperipherals', '--all',
'--existing', file('src/main/resources').toString(),
'--existing', file('src/generated/resources').toString(),
'--output', file('src/generated/resources/')
mods {
advancedperipherals {
source sourceSets.main
}
}
}
testClient {
workingDirectory project.file('test-files/client')
parent runs.client
mods {
aptest {
source sourceSets.testMod
}
}
lazyToken('minecraft_classpath') {
(configurations.implementationExtra.copyRecursive().resolve())
.collect { it.absolutePath }
.join(File.pathSeparator)
}
}
testServer {
workingDirectory project.file('test-files/server')
parent runs.server
mods {
aptest {
source sourceSets.testMod
}
}
lazyToken('minecraft_classpath') {
(configurations.implementationExtra.copyRecursive().resolve())
.collect { it.absolutePath }
.join(File.pathSeparator)
}
}
}
}
repositories {
mavenCentral()
maven {
name = "Blamejared maven botania patchouli"
url = 'https://maven.blamejared.com'
content {
includeGroup("vazkii.botania")
includeGroup("vazkii.patchouli")
}
}
maven {
name = "Squiddev maven cct"
url = 'https://squiddev.cc/maven/'
content {
includeGroup("cc.tweaked")
includeModule("org.squiddev", "Cobalt")
}
}
maven {
name = "Theillusivec4 maven curios"
url = "https://maven.theillusivec4.top/"
content {
includeGroup("top.theillusivec4.curios")
}
}
maven {
name = "LDT Team minecolonies"
url = 'https://ldtteam.jfrog.io/ldtteam/modding'
content {
includeGroup "com.ldtteam"
}
}
maven {
name = "Modmaven Jei"
url = 'https://modmaven.dev/'
content {
includeGroup("mezz.jei")
includeGroup("appeng")
includeGroup("mekanism")
}
}
maven {
name = "Create maven"
url = "https://maven.tterrag.com/"
content {
includeGroup("com.simibubi.create")
includeGroup("com.jozufozu.flywheel")
includeGroup("com.tterrag.registrate")
}
}
maven {
name = "SirEdvin's private repository"
url = "https://repo.repsy.io/mvn/siredvin/default"
content {
includeGroup("site.siredvin.ttoolkit")
}
}
maven {
name = "Shedaniel cloth"
url = "https://maven.shedaniel.me/"
content {
includeGroup("dev.architectury")
includeGroup("me.shedaniel.cloth")
}
}
maven {
url = uri("https://maven.pkg.github.com/refinedmods/refinedstorage")
credentials {
username = "anything"
password = "\u0067hp_oGjcDFCn8jeTzIj4Ke9pLoEVtpnZMP4VQgaX"
}
content {
includeModule("com.refinedmods", "refinedstorage")
}
}
maven {
name = 'Kotlin for Forge'
url = 'https://thedarkcolour.github.io/KotlinForForge/'
content {
includeModule("thedarkcolour", "kotlinforforge")
}
}
maven {
url = "https://cursemaven.com"
content {
includeGroup "curse.maven"
}
}
}
configurations {
implementationExtra
testModImplementation.extendsFrom(implementation)
testModImplementation.extendsFrom(testImplementation)
}
dependencies {
// If some of the dependencies are not needed in the dev environment, you can comment the `runtimeOnly` line so it
// will not be included in the client.
// Minimal requirements
compileOnly "org.jetbrains:annotations:${jb_annotations}"
minecraft "net.neoforged:forge:${minecraft_version}-${neo_version}"
implementation fg.deobf("cc.tweaked:cc-tweaked-${minecraft_version}-forge:${cc_version}")
// Compile-time API required
// Ae2
compileOnly fg.deobf("appeng:appliedenergistics2-forge:${appliedenergistics_version}")
// Curios
compileOnly fg.deobf("top.theillusivec4.curios:curios-forge:${curios_version}:api")
// Minimal requirements end
// Extended requirements
// We don't use the api since we need a specific class from mekanism
compileOnly fg.deobf("mekanism:Mekanism:${mekanism_version}")
runtimeOnly fg.deobf("mekanism:Mekanism:${mekanism_version}")
// runtimeOnly fg.deobf("mekanism:Mekanism:${mekanism_version}")// core
// Applied Energistics 2
runtimeOnly fg.deobf("appeng:appliedenergistics2-forge:${appliedenergistics_version}")
// Applied Mekanistics
implementation fg.deobf("curse.maven:applied-mekanistics-574300:${appliedmekanistics_version}")
// Curios
runtimeOnly fg.deobf("top.theillusivec4.curios:curios-forge:${curios_version}")
// Refined Storage
implementation fg.deobf("com.refinedmods:refinedstorage:${refinedstorage_version}") {
transitive false
}
// AE2 Things
compileOnly fg.deobf("curse.maven:ae2things-609977:${ae2things_version}-sources")
runtimeOnly fg.deobf("curse.maven:ae2things-609977:${ae2things_version}-sources")
// AE2 Additions
compileOnly fg.deobf("curse.maven:ae-additions-493962:${ae2additions_version}")
runtimeOnly fg.deobf("curse.maven:ae-additions-493962:${ae2additions_version}")
implementation fg.deobf("thedarkcolour:kotlinforforge:${kotlinforforge_version}")
// Botania
compileOnly fg.deobf("vazkii.botania:Botania:${botania_version}")
runtimeOnly fg.deobf("vazkii.botania:Botania:${botania_version}")
// Minecolonies
// Remove/Comment this section if you want to use runData.
runtimeOnly fg.deobf("com.ldtteam:minecolonies:${minecolonies_version}")
runtimeOnly fg.deobf("com.ldtteam:structurize:${structurize_version}")
runtimeOnly fg.deobf("com.ldtteam:domum_ornamentum:${domumornamentum_version}:universal")
runtimeOnly fg.deobf("com.ldtteam:blockui:${blockui_version}")
compileOnly fg.deobf("com.ldtteam:minecolonies:${minecolonies_version}")
compileOnly fg.deobf("com.ldtteam:structurize:${structurize_version}")
compileOnly fg.deobf("com.ldtteam:domum_ornamentum:${domumornamentum_version}:universal")
compileOnly fg.deobf("com.ldtteam:blockui:${blockui_version}")
//Patchouli
runtimeOnly fg.deobf("vazkii.patchouli:Patchouli:${patchouli_version}-FORGE")
// Create
compileOnly fg.deobf("com.simibubi.create:create-1.20.1:${create_version}:all")
runtimeOnly fg.deobf("com.simibubi.create:create-1.20.1:${create_version}:all")
//Powah
implementation fg.deobf("curse.maven:powah-633483:${powah_version}")
implementation fg.deobf("me.shedaniel.cloth:cloth-config-forge:11.1.106")
implementation fg.deobf("dev.architectury:architectury-forge:9.1.10")
//Removed until fully ported
//testImplementation fg.deobf("site.siredvin.ttoolkit:ttoolkit-${minecraft_version}:${ttoolkit_version}")
testImplementation "org.junit.jupiter:junit-jupiter-api:${junit_version}"
testImplementation "org.junit.jupiter:junit-jupiter-params:${junit_version}"
testImplementation "org.hamcrest:hamcrest:${hamcrest_version}"
testImplementation "org.jetbrains.kotlin:kotlin-reflect:${kotlin_version}"
testImplementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:${kotlinx_coroutines_version}"
testModImplementation sourceSets.main.output
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:${junit_version}"
// Testing stuff
// JEI
implementation fg.deobf("mezz.jei:jei-${jei_version}")
// Create Crafts & Additions
compileOnly fg.deobf("curse.maven:createaddition-439890:${createadditions_version}")
runtimeOnly fg.deobf("curse.maven:createaddition-439890:${createadditions_version}")
}
changelog {
version = "${project.version}"
path = "${project.projectDir}/CHANGELOG.md"
header = "[${minecraft_version}-${-> version.get()}] - ${new SimpleDateFormat("yyyy-MM-dd").format(new Date())}"
//Valid patterns would be
//1.16.5-1.1.1.1b
//1.18-1.0r
//1.19-1.0.0a
headerParserRegex = ~/\d+(\.\d+){1,2}-\d+(\.\d+){1,3}\w/
itemPrefix = "-"
keepUnreleasedSection = true
unreleasedTerm = "[Unreleased]"
groups = []
}
compileTestModJava {
dependsOn(compileJava)
}
task setupServer(type: Copy) {
group "test server"
description "Sets up the environment for the test server."
from("src/testMod/server-files") {
include "eula.txt"
include "server.properties"
}
into "test-files/server"
}
["Client", "Server"].forEach { name ->
tasks.register("test$name", JavaExec.class).configure {
it.group('In-game tests')
it.description("Runs tests on a temporary Minecraft instance.")
it.dependsOn(setupServer, "prepareRunTest$name", "cleanTest$name", 'compileTestModJava')
JavaExec exec = tasks.getByName("runTest$name")
exec.copyTo(it)
it.setClasspath(exec.getClasspath())
it.mainClass = exec.mainClass
it.setArgs(exec.getArgs())
it.systemProperty('forge.logging.console.level', 'debug')
it.systemProperty('ttoolkit.run', 'true')
}
}
test {
useJUnitPlatform()
testLogging {
events "skipped", "failed"
}
}
afterEvaluate {
tasks.withType(JavaCompile) {
options.compilerArgs << "-Xmaxerrs" << "2000"
}
}
jar {
manifest({
attributes(["Specification-Title" : "advancedperipherals",
"Specification-Vendor" : "Srendi",
"Specification-Version" : "${version}",
"Implementation-Title" : "advancedperipherals",
"Implementation-Version" : "${version}",
"Implementation-Vendor" : "Srendi",
"Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ")])
})
archiveFileName = "AdvancedPeripherals-${minecraft_version}-${mod_version}.jar"
}
jar.finalizedBy('reobfJar')
tasks.withType(Checkstyle) {
reports {
xml.required = false
html.required = false
}
// Checkstyle is compatible with the configuration cache, however we need to disable it to prevent a build issue with teamcity
notCompatibleWithConfigurationCache()
outputs.upToDateWhen { false }
}
tasks.named('processResources', ProcessResources).configure {
var replaceProperties = [minecraft_version : minecraft_version,
neo_version : neo_version,
loader_version : loader_version,
mod_id : mod_id,
version : version,
cc_version : cc_version,
curios_version : curios_version,
minecolonies_version : minecolonies_version,
appliedenergistics_version: appliedenergistics_version,
patchouli_version : patchouli_version,
refinedstorage_version : refinedstorage_version,
botania_version : botania_version,
mekanism_version : mekanism_version,
ae2things_version : ae2things_version,
powah_version : powah_version,]
inputs.properties replaceProperties
filesMatching(['META-INF/mods.toml', 'pack.mcmeta']) {
expand replaceProperties + [project: project]
}
}
// Used to do some magic with teamcity
task commitAndPush() {
doLast {
def baseMessage = project.hasProperty('commitMessage') ? commitMessage : 'No commit message provided'
def message = baseMessage.replace("{version}", "${minecraft_version}-${version}")
exec {
commandLine 'git', 'add', '.'
}
exec {
commandLine 'git', 'commit', '-m', message
}
}
}
tasks.register('publishCurseForge', TaskPublishCurseForge, { task ->
setGroup("publishing")
setDescription("Upload Advanced Peripherals to CurseForge")
// This token is used to authenticate with CurseForge. It should be handled
// with the same level of care and security as your actual password. You
// should never share your token with an untrusted source or publish it
// publicly to GitHub or embed it within a project. The best practice is to
// store this token in an environment variable or a build secret.
apiToken = curseforgeKey
// Tells CurseForgeGradle to publish the output of the jar task. This will
// return a UploadArtifact object that can be used to further configure the
// file.
task.upload(431725, jar) { file ->
try {
file.changelog = "${project.changelog.get("${minecraft_version}-${project.version}").withHeader(false).toText()}"
file.changelogType = "markdown"
} catch (err) {
System.out.println(err)
file.changelog = ""
}
addOptional('applied-energistics-2', 'curios', 'mekanism', 'refined-storage')
addRequirement('cc-tweaked')
addModLoader("forge", "neoforge")
releaseType = "${release_type}"
}
})
githubRelease {
releaseAssets = jar.archiveFile
if (githubKey != null)
token = githubKey
owner = "IntelligenceModding"
repo = "AdvancedPeripherals"
tagName = "${minecraft_version}-${version}"
releaseName = "${minecraft_version}-${version}"
targetCommitish = "release/${minecraft_version}"
generateReleaseNotes = false
try {
body = "${project.changelog.get("${minecraft_version}-${version}").withHeader(false).toText()}"
} catch (err) {
System.out.println(err)
body = ""
}
draft = false
prerelease = !release_type.equalsIgnoreCase("release")
}
modrinth {
token = modrinthKey
projectId = 'SOw6jD6x'
versionNumber = "${minecraft_version}-${project.version}"
versionName = "Advanced Peripherals ${minecraft_version} ${version}"
versionType = release_type
uploadFile = jar
gameVersions = [minecraft_version]
loaders = ["forge", "neoforge"]
dependencies {
required.project "cc-tweaked"
}
try {
changelog = "${project.changelog.get("${minecraft_version}-${project.version}").withHeader(false).toText()}"
} catch (err) {
System.out.println(err)
changelog = ""
}
}
publishing {
publications { PublicationContainer publicationContainer ->
publicationContainer.register("maven", MavenPublication) { MavenPublication publication ->
publication.from((SoftwareComponent) components.java)
publication.groupId = project.group
publication.version = isSnapshotVersion ? "${minecraft_version}-${version}-${project.teamcityBuild}" : "${minecraft_version}-${version}"
publication.artifactId = isSnapshotVersion ? "advancedperipherals-snapshots" : "advancedperipherals"
publication.artifacts = [jar, sourcesJar]
publication.pom {
name.set("AdvancedPeripherals")
packaging = 'jar'
description.set('Advanced Peripherals provides multiple extensions for ComputerCraft in form of Peripherals, Pocket Upgrades, Turtles or new gear.\n' +
'It also integrates with multiple third party mods.')
url.set('https://docs.intelligence-modding.de/')
scm {
url.set('https://github.com/SirEndii/AdvancedPeripherals.git')
}
issueManagement {
system.set('github')
url.set('https://github.com/SirEndii/AdvancedPeripherals/issues')
}
licenses {
license {
name.set('Apache-2.0')
distribution.set('repo')
}
}
withXml {
NodeList dependencies = asNode().dependencies
NodeList allDeps = dependencies.'*'
//TODO: Needs to be changed in 1.20.2 since neoforge then changes the packages names.
// Remove forge deps
allDeps.<Node> findAll() { Node el ->
el.artifactId.text() == 'forge' && el.groupId.text() == 'net.minecraftforge'
}.forEach() { Node el ->
el.parent().remove(el)
}
//remove ForgeGradle's mapped suffix from versions & set as optional so anyone else doesn't inherit them
allDeps.<Node> findAll() { Node el ->
el.version.text().contains('_mapped_')
}.each { Node el ->
el.version.each { Node version ->
def versionText = version.text()
version.setValue(versionText.substring(0, versionText.indexOf('_mapped_')))
}
el.appendNode('optional', true)
}
}
}
}
}
repositories {
maven {
name = "public"
url = "https://mvn.intelligence-modding.de/Intelligence"
credentials {
username = repositoryName
password = repositoryKey
}
}
}
}