forked from IntelligenceModding/AdvancedPeripherals
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
454 lines (388 loc) · 14.1 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
import java.text.SimpleDateFormat
buildscript {
repositories {
maven {
name = "Minecraft Forge maven"
url = "https://maven.minecraftforge.net"
}
maven {
name = "Parchment maven"
url = "https://maven.parchmentmc.org"
}
mavenCentral()
gradlePluginPortal()
}
dependencies {
classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '5.1+', changing: true
classpath 'org.parchmentmc:librarian:1.+'
}
}
plugins {
id "maven-publish"
id 'com.matthewprenger.cursegradle' version '1.4.0'
id 'org.jetbrains.changelog' version '1.2.1'
id "com.modrinth.minotaur" version "2.+"
id "org.jetbrains.kotlin.jvm" version "1.6.10"
id "org.sonarqube" version "3.5.0.2730"
id 'checkstyle'
}
apply plugin: 'net.minecraftforge.gradle'
apply plugin: 'org.parchmentmc.librarian.forgegradle'
java.toolchain.languageVersion = JavaLanguageVersion.of(17)
wrapper {
gradleVersion = '7.5'
distributionType = Wrapper.DistributionType.ALL
}
def isSnapshotVersion = Boolean.valueOf(System.getProperty("snapshot"))
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")
sonarqube {
properties {
property "sonar.projectKey", "SirEndii_AdvancedPeripherals"
property "sonar.organization", "sirendii"
property "sonar.host.url", "https://sonarcloud.io"
}
}
// 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'
}
maven {
name = "Squiddev maven cct"
url = 'https://squiddev.cc/maven/'
}
maven {
name = "Theillusivec4 maven curios"
url = "https://maven.theillusivec4.top/"
}
maven {
name = "LDT Team minecolonies"
url = 'https://ldtteam.jfrog.io/ldtteam/modding'
}
maven {
name = "Modmaven jei"
url = 'https://modmaven.dev/'
}
maven {
name = "Create maven"
url = "https://maven.tterrag.com/"
content {
includeGroup "com.simibubi.create"
includeGroup "com.jozufozu.flywheel"
}
}
maven {
name = "Srendi Space repository"
url = "https://maven.pkg.jetbrains.space/intelligence/p/advancedperipherals/ap-repository"
credentials {
username = spaceUsername
password = spacePassword
}
}
maven {
name = "SirEdvin's private repository"
url = "https://repo.repsy.io/mvn/siredvin/default"
content {
includeGroup "site.siredvin.ttoolkit"
}
}
maven {
url = uri("https://maven.pkg.github.com/refinedmods/refinedstorage")
credentials {
username = "anything"
password = "\u0067hp_oGjcDFCn8jeTzIj4Ke9pLoEVtpnZMP4VQgaX"
}
}
maven {
url "https://cursemaven.com"
content {
includeGroup "curse.maven"
}
}
}
configurations {
implementationExtra
testModImplementation.extendsFrom(implementation)
testModImplementation.extendsFrom(testImplementation)
}
dependencies {
// Minimal requirements
compileOnly "org.jetbrains:annotations:${jb_annotations}"
minecraft "net.minecraftforge:forge:${minecraft_version}-${forge_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 "mekanism:Mekanism:${mekanism_version}"
// runtimeOnly fg.deobf("mekanism:Mekanism:${mekanism_version}")// core
// Applied Energistics 2
runtimeOnly fg.deobf("appeng:appliedenergistics2-forge:${appliedenergistics_version}")
// Curios
runtimeOnly fg.deobf("top.theillusivec4.curios:curios-forge:${curios_version}")
// Refined Storage
compileOnly fg.deobf("com.refinedmods:refinedstorage:${refinedstorage_version}") {
transitive false
}
// AE2 Things - removed until ported
// compileOnly "curse.maven:ae2things-609977:${ae2things_version}-sources"
// runtimeOnly fg.deobf("curse.maven:ae2things-609977:${ae2things_version}-sources")
// Botania
compileOnly fg.deobf("vazkii.botania:Botania:${botania_version}")
// Minecolonies
// Change to compileOnly when running `runData`
compileOnly fg.deobf("com.ldtteam:minecolonies:${minecolonies_version}")
compileOnly fg.deobf("com.ldtteam:structurize:${structurize_version}")
compileOnly fg.deobf("com.ldtteam:multipiston:${multipiston_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}")
// Create
compileOnly fg.deobf("com.simibubi.create:create-1.19.2:${create_version}:all")
compileOnly fg.deobf("com.jozufozu.flywheel:flywheel-forge-${minecraft_version}:${flywheel_version}")
//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}")
}
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")
])
})
}
jar.finalizedBy('reobfJar')
curseforge {
apiKey = curseforgeKey
project {
id = "431725"
releaseType = "${release_type}"
mainArtifact(jar) {
displayName = "Advanced Peripherals ${minecraft_version} ${version}"
relations {
requiredDependency 'cc-tweaked'
tool 'curios'
}
}
addGameVersion "${minecraft_version}"
try {
changelog = "${project.changelog.get("${minecraft_version}-${project.version}").withHeader(false).toText()}"
changelogType = "markdown"
} catch (err) {
System.out.println(err)
changelog = ""
}
}
}
modrinth {
token = modrinthKey // This is the default. Remember to have the MODRINTH_TOKEN environment variable set or else this will fail, or set it to whatever you want - just make sure it stays private!
projectId = 'SOw6jD6x' // This can be the project ID or the slug. Either will work!
versionNumber = "${minecraft_version}-${project.version}"
versionName = "Advanced Peripherals ${minecraft_version} ${version}"
versionType = release_type
uploadFile = jar // With Loom, this MUST be set to `remapJar` instead of `jar`!
gameVersions = [minecraft_version] // Must be an array, even with only one version
loaders = ["forge"] // Must also be an array - no need to specify this if you're using Loom or ForgeGradl
try {
changelog = "${project.changelog.get("${minecraft_version}-${project.version}").withHeader(false).toText()}"
} catch (err) {
System.out.println(err)
changelog = ""
}
}
publishing {
repositories {
maven {
url "https://maven.pkg.jetbrains.space/intelligence/p/advancedperipherals/ap-repository"
credentials {
username = spaceUsername
password = spacePassword
}
}
}
publications {
gpr(MavenPublication) {
from(components.java)
}
}
}