-
-
Notifications
You must be signed in to change notification settings - Fork 101
Expand file tree
/
Copy pathbuild.gradle
More file actions
523 lines (458 loc) · 17.7 KB
/
build.gradle
File metadata and controls
523 lines (458 loc) · 17.7 KB
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
import net.darkhax.curseforgegradle.TaskPublishCurseForge
import java.text.SimpleDateFormat
plugins {
id 'checkstyle'
id 'idea'
id 'java'
id 'maven-publish'
id 'com.github.breadmoirai.github-release' version '2.5.2'
id 'com.modrinth.minotaur' version '2.+'
id 'net.darkhax.curseforgegradle' version '1.1.16'
id 'net.neoforged.moddev' version '2.+'
id 'org.jetbrains.changelog' version '1.2.1'
}
java {
toolchain {
languageVersion = JavaLanguageVersion.of(21)
}
withSourcesJar()
}
wrapper {
gradleVersion = '8.11'
distributionType = Wrapper.DistributionType.BIN
}
def isSnapshotVersion = project.hasProperty('teamcityBuild')
def githubUser = 'IntelligenceModding'
def githubRepo = 'AdvancedPeripherals'
version = "${mod_version}" + (isSnapshotVersion ? "-SNAPSHOT" : "") + "${mod_artifact_suffix}"
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' }
neoForge {
// Specify the version of NeoForge to use.
version = project.neo_version
parchment {
mappingsVersion = project.parchment_mappings_version
minecraftVersion = project.parchment_minecraft_version
}
validateAccessTransformers = true
runs {
// applies to all the run configs below
configureEach {
systemProperty 'forge.logging.markers', 'REGISTRIES'
logLevel = org.slf4j.event.Level.DEBUG
}
client {
client()
systemProperty 'neoforge.enabledGameTestNamespaces', project.mod_id
}
server {
server()
systemProperty 'neoforge.enabledGameTestNamespaces', project.mod_id
}
gameTestServer {
type = "gameTestServer"
systemProperty 'neoforge.enabledGameTestNamespaces', project.mod_id
}
data {
data()
programArguments.addAll '--mod', project.mod_id, '--all', '--output', file('src/generated/resources/').getAbsolutePath(), '--existing', file('src/main/resources/').getAbsolutePath()
}
}
mods {
"${mod_id}" {
sourceSet(sourceSets.main)
}
}
}
repositories {
mavenCentral()
maven {
name = "Intelligence Mirror Repo"
url = "https://mvn.intelligence-modding.de/Minecraft"
content {
includeGroup("com.refinedmods.refinedstorage")
}
}
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://maven.squiddev.cc'
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.createmod.net"
content {
includeGroup("com.simibubi.create")
includeGroup("dev.engine-room.flywheel")
includeGroup("net.createmod.ponder")
}
}
maven {
name = "Create Registrate maven"
url = "https://maven.ithundxr.dev/snapshots"
content {
includeGroup("com.tterrag.registrate")
}
}
maven {
name = "TerraformersMC EMI"
url = "https://maven.terraformersmc.com/"
}
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 {
name = "EMI"
url = uri("https://maven.terraformersmc.com/")
}
maven {
name = 'Kotlin for Forge'
url = 'https://thedarkcolour.github.io/KotlinForForge/'
content {
includeModule("thedarkcolour", "kotlinforforge")
}
}
exclusiveContent {
forRepository {
maven {
url = "https://cursemaven.com"
}
}
filter {
includeGroup("curse.maven")
}
}
exclusiveContent {
forRepository {
maven {
url = "https://api.modrinth.com/maven"
}
}
filter {
includeGroup("maven.modrinth")
}
}
}
configurations {
implementationExtra
testModImplementation.extendsFrom(implementation)
testModImplementation.extendsFrom(testImplementation)
runtimeClasspath.extendsFrom localRuntime
}
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}"
implementation "net.neoforged:neoforge:${neo_version}"
implementation "cc.tweaked:cc-tweaked-${minecraft_version}-forge:${cc_version}"
compileOnly "cc.tweaked:cc-tweaked-${minecraft_version}-core:${cc_version}"
// Minimal requirements end
compileOnly("com.refinedmods.refinedstorage:refinedstorage-neoforge:${refinedstorage_version}")
runtimeOnly("com.refinedmods.refinedstorage:refinedstorage-neoforge:${refinedstorage_version}") {
transitive = false
}
// Transitive prevents that this dependency would load other dependencies which are used by refined storage and are faulty marked
compileOnly("com.refinedmods.refinedstorage:refinedstorage-mekanism-integration:${refinedstorage_mekanism_version}")
runtimeOnly("com.refinedmods.refinedstorage:refinedstorage-mekanism-integration:${refinedstorage_mekanism_version}") {
transitive = false
}
// Extended requirements
// We don't use the api since we need a specific class from mekanism
compileOnly "mekanism:Mekanism:${mekanism_version}"
runtimeOnly "mekanism:Mekanism:${mekanism_version}"
// Applied Energistics 2
compileOnly "org.appliedenergistics:appliedenergistics2:${appliedenergistics_version}"
runtimeOnly "org.appliedenergistics:appliedenergistics2:${appliedenergistics_version}"
// Applied Mekanistics
compileOnly "curse.maven:applied-mekanistics-574300:${appliedmekanistics_version}"
runtimeOnly "curse.maven:applied-mekanistics-574300:${appliedmekanistics_version}"
// AE2 Things
compileOnly "curse.maven:ae2things-609977:${ae2things_version}-sources"
runtimeOnly "curse.maven:ae2things-609977:${ae2things_version}-sources"
implementation ("com.simibubi.create:create-${minecraft_version}:${create_version}:slim") { transitive = false }
implementation "net.createmod.ponder:Ponder-NeoForge-${minecraft_version}:${ponder_version}"
compileOnly "dev.engine-room.flywheel:flywheel-neoforge-api-${minecraft_version}:${flywheel_version}"
runtimeOnly "dev.engine-room.flywheel:flywheel-neoforge-${minecraft_version}:${flywheel_version}"
implementation "com.tterrag.registrate:Registrate:${registrate_version}"
// Minecolonies
compileOnly "com.ldtteam:blockui:${blockui_version}"
compileOnly "com.ldtteam:domum-ornamentum:${domumornamentum_version}"
compileOnly "com.ldtteam:minecolonies:${minecolonies_version}"
compileOnly "com.ldtteam:structurize:${structurize_version}"
// Remove/Comment this section if you want to use runData.
runtimeOnly "com.ldtteam:blockui:${blockui_version}"
runtimeOnly "com.ldtteam:domum-ornamentum:${domumornamentum_version}"
runtimeOnly "com.ldtteam:minecolonies:${minecolonies_version}"
runtimeOnly "com.ldtteam:structurize:${structurize_version}"
// Patchouli
compileOnly "vazkii.patchouli:Patchouli:${patchouli_version}-NEOFORGE"
runtimeOnly "vazkii.patchouli:Patchouli:${patchouli_version}-NEOFORGE"
// Powah
compileOnly "curse.maven:powah-633483:${powah_version}"
runtimeOnly "me.shedaniel.cloth:cloth-config-neoforge:${cloth_config_version}"
runtimeOnly "curse.maven:powah-633483:${powah_version}"
testModImplementation sourceSets.main.output
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:${junit_version}"
// Testing stuff
// EMI
runtimeOnly "dev.emi:emi-neoforge:${emi_version}"
// Spark
runtimeOnly "maven.modrinth:spark:1.10.124-neoforge-1.21.1"
}
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 = []
}
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"
}
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.withType(ProcessResources).configureEach {
var replaceProperties = [minecraft_version : minecraft_version,
neo_version : neo_version,
loader_version : loader_version,
mod_id : mod_id,
version : version,
cc_version : cc_version,
minecolonies_version : minecolonies_version,
appliedenergistics_version: appliedenergistics_version,
patchouli_version : patchouli_version,
mekanism_version : mekanism_version,
ae2things_version : ae2things_version,
powah_version : powah_version,]
inputs.properties replaceProperties
filesMatching(['META-INF/neoforge.mods.toml']) {
expand replaceProperties
}
}
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("neoforge")
releaseType = "${release_type}"
}
})
githubRelease {
releaseAssets = jar.archiveFile
if (githubKey != null)
token = githubKey
owner = githubUser
repo = githubRepo
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("alpha")
}
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 = ["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/${githubUser}/${githubRepo}.git")
}
issueManagement {
system.set('github')
url.set("https://github.com/${githubUser}/${githubRepo}/issues")
}
licenses {
license {
name.set('Apache-2.0')
distribution.set('repo')
}
}
withXml {
NodeList dependencies = asNode().dependencies
NodeList allDeps = dependencies.'*'
allDeps.<Node> findAll() { Node el ->
el.artifactId.text() == 'forge' && el.groupId.text() == 'net.neoforged'
}.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
}
}
}
}
// IDEA no longer automatically downloads sources/javadoc jars for dependencies, so we need to explicitly enable the behavior.
idea {
module {
downloadSources = true
downloadJavadoc = true
}
}