Skip to content
This repository was archived by the owner on Jul 18, 2023. It is now read-only.

Commit 98b753f

Browse files
committed
chore: update test mod, don't run client mixins on the server
use gametest framework
1 parent 63eb74b commit 98b753f

File tree

13 files changed

+69
-414
lines changed

13 files changed

+69
-414
lines changed

build.gradle.kts

Lines changed: 41 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -9,49 +9,50 @@ plugins {
99
}
1010

1111
val mc = "1.17.1"
12-
val yarn = "29"
12+
val yarn = "52"
1313
val loader = "0.11.6"
14-
val fabric = "0.37.1+1.17"
15-
val lba = "0.9.0"
14+
val fabric = "0.40.0+1.17"
15+
val lba = "0.9.1-pre.1"
1616

1717
group = "dev.galacticraft"
18-
version ="0.4.0-prealpha.18+$mc"
18+
version ="0.4.0-prealpha.19+$mc"
1919

2020
base.archivesName.set("GalacticraftAPI")
2121

22-
val testmodSourceSet = sourceSets.create("testmod") {
22+
java {
23+
targetCompatibility = JavaVersion.VERSION_16
24+
sourceCompatibility = JavaVersion.VERSION_16
25+
26+
withSourcesJar()
27+
withJavadocJar()
28+
}
29+
30+
val gametestSourceSet = sourceSets.create("gametest") {
2331
compileClasspath += sourceSets.main.get().compileClasspath
2432
runtimeClasspath += sourceSets.main.get().runtimeClasspath
25-
java.srcDir("src/testmod/java")
26-
resources.srcDir("src/testmod/resources")
33+
java.srcDir("src/gametest/java")
34+
resources.srcDir("src/gametest/resources")
2735
}
2836

2937
loom {
3038
accessWidenerPath.set(project.file("src/main/resources/galacticraft-api.accesswidener"))
3139
mixin {
32-
add(sourceSets.getByName("testmod"), "gc-testmod.refmap.json")
33-
add(sourceSets.getByName("main"), "galacticraft-api.refmap.json")
40+
add(sourceSets.main.get(), "galacticraft-api.refmap.json")
3441
}
3542

3643
runs {
37-
register("TestModClient") {
38-
client()
39-
source(testmodSourceSet)
40-
vmArgs("-ea")
41-
property("fabric.log.level", "debug")
42-
name("TestMod Client")
43-
}
44-
register("TestModServer") {
44+
register("gametest") {
4545
server()
46-
source(testmodSourceSet)
47-
vmArgs("-ea",)
46+
name("Game Test")
47+
source(gametestSourceSet)
4848
property("fabric.log.level", "debug")
49-
name("TestMod Server")
49+
vmArg("-Dfabric-api.gametest=true")
50+
vmArg("-ea")
5051
}
5152
}
5253
}
5354

54-
val testmodCompile by configurations.creating { extendsFrom(configurations.runtimeOnly.get()) }
55+
val gametestCompile by configurations.creating { extendsFrom(configurations.runtimeOnly.get()) }
5556

5657
repositories {
5758
maven("https://alexiil.uk/maven/") {
@@ -69,6 +70,7 @@ dependencies {
6970
listOf(
7071
"fabric-api-base",
7172
"fabric-command-api-v1",
73+
"fabric-gametest-api-v1",
7274
"fabric-lifecycle-events-v1",
7375
"fabric-networking-api-v1",
7476
"fabric-registry-sync-v0",
@@ -82,35 +84,25 @@ dependencies {
8284
modImplementation("alexiil.mc.lib:libblockattributes-items:$lba")
8385
modRuntime("net.fabricmc.fabric-api:fabric-api:$fabric")
8486

85-
testmodCompile(sourceSets.main.get().output)
87+
gametestCompile(sourceSets.main.get().output)
8688
}
8789

8890
tasks.processResources {
8991
inputs.property("version", project.version)
90-
duplicatesStrategy = DuplicatesStrategy.WARN
9192

92-
from(sourceSets.main.get().resources.srcDirs) {
93-
include("fabric.mod.json")
94-
expand(mutableMapOf("version" to project.version))
93+
filesMatching("fabric.mod.json") {
94+
expand("version" to project.version)
9595
}
9696

97-
from(sourceSets.main.get().resources.srcDirs) {
98-
exclude("fabric.mod.json")
97+
// Minify json resources
98+
// https://stackoverflow.com/questions/41028030/gradle-minimize-json-resources-in-processresources#41029113
99+
doLast {
100+
fileTree(mapOf("dir" to outputs.files.asPath, "includes" to listOf("**/*.json", "**/*.mcmeta"))).forEach {
101+
file: File -> file.writeText(groovy.json.JsonOutput.toJson(groovy.json.JsonSlurper().parse(file)))
102+
}
99103
}
100104
}
101105

102-
tasks.getByName<ProcessResources>("processTestmodResources") {
103-
duplicatesStrategy = DuplicatesStrategy.WARN
104-
}
105-
106-
java {
107-
withSourcesJar()
108-
withJavadocJar()
109-
110-
targetCompatibility = JavaVersion.VERSION_16
111-
sourceCompatibility = JavaVersion.VERSION_16
112-
}
113-
114106
tasks.withType<JavaCompile> {
115107
dependsOn(tasks.checkLicenses)
116108
options.encoding = "UTF-8"
@@ -135,14 +127,14 @@ tasks.remapSourcesJar.configure {
135127
tasks.jar {
136128
from("LICENSE")
137129
manifest {
138-
attributes(mapOf(
130+
attributes(
139131
"Implementation-Title" to "GalacticraftAPI",
140132
"Implementation-Version" to "${project.version}",
141133
"Implementation-Vendor" to "Team Galacticraft",
142134
"Implementation-Timestamp" to DateTimeFormatter.ISO_DATE_TIME,
143135
"Maven-Artifact" to "${project.group}:GalacticraftAPI:${project.version}",
144136
"ModSide" to "BOTH"
145-
))
137+
)
146138
}
147139
}
148140

@@ -179,4 +171,10 @@ license {
179171
set("year", Year.now().value)
180172
set("company", "Team Galacticraft")
181173
}
182-
}
174+
}
175+
176+
tasks.named<ProcessResources>("processGametestResources") {
177+
duplicatesStrategy = DuplicatesStrategy.WARN
178+
}
179+
180+
tasks.getByName("gametestClasses").dependsOn("classes")
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-7.1.1-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists

src/testmod/java/dev/galacticraft/api/testmod/GCApiTestMod.java renamed to src/gametest/java/dev/galacticraft/api/gametest/GalacticraftApiTestSuite.java

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,15 @@
2020
* SOFTWARE.
2121
*/
2222

23-
package dev.galacticraft.api.testmod;
23+
package dev.galacticraft.api.gametest;
2424

25-
import net.fabricmc.api.ModInitializer;
26-
import org.apache.logging.log4j.LogManager;
27-
import org.apache.logging.log4j.Logger;
25+
import net.fabricmc.fabric.api.gametest.v1.FabricGameTest;
26+
import net.minecraft.test.GameTest;
27+
import net.minecraft.test.TestContext;
2828

29-
public class GCApiTestMod implements ModInitializer {
30-
public static final Logger LOGGER = LogManager.getLogger();
31-
@Override
32-
public void onInitialize() {
33-
LOGGER.info("Loaded test mod!");
29+
public class GalacticraftApiTestSuite implements FabricGameTest {
30+
@GameTest(structureName = EMPTY_STRUCTURE)
31+
public void emptyTest(TestContext context) {
32+
context.addInstantFinalTask(() -> {});
3433
}
3534
}

src/testmod/resources/data/gc-testmod/advancements/custom/example_part.json renamed to src/gametest/resources/data/gc-api-test/advancements/custom/example_part.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
{
2-
"parent": "gc-testmod:custom/root",
2+
"parent": "gc-api-test:custom/root",
33
"display": {
44
"icon": {
55
"item": "minecraft:diamond_block"
66
},
77
"title": {
8-
"translate": "gc-testmod.advancements.custom.diamond_block.title"
8+
"translate": "gc-api-test.advancements.custom.diamond_block.title"
99
},
1010
"description": {
11-
"translate": "gc-testmod.advancements.custom.diamond_block.description"
11+
"translate": "gc-api-test.advancements.custom.diamond_block.description"
1212
},
1313
"frame": "challenge",
1414
"show_toast": true,
@@ -17,7 +17,7 @@
1717
},
1818
"rewards": {
1919
"rocket_parts": [
20-
"gc-testmod:test"
20+
"gc-api-test:test"
2121
]
2222
},
2323
"criteria": {

src/testmod/resources/data/gc-testmod/advancements/custom/root.json renamed to src/gametest/resources/data/gc-api-test/advancements/custom/root.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
"item": "minecraft:gold_block"
55
},
66
"title": {
7-
"translate": "gc-testmod.advancements.custom.root.title"
7+
"translate": "gc-api-test.advancements.custom.root.title"
88
},
99
"description": {
10-
"translate": "gc-testmod.advancements.custom.root.description"
10+
"translate": "gc-api-test.advancements.custom.root.description"
1111
},
1212
"frame": "task",
1313
"show_toast": false,
Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,32 @@
11
{
22
"schemaVersion": 1,
3-
"id": "gc-testmod",
3+
"id": "gc-api-test",
44
"version": "$version",
55

66
"name": "Galacticraft API Test Mod",
77
"description": "Test mod for the Addon API for the FabricMC port of Galacticraft.",
88
"license": "MIT",
99
"contact": {
10-
"homepage": "https://galacticraft.team",
11-
"sources": "https://github.com/TeamGalacticraft/Addon-API",
12-
"issues": "https://github.com/TeamGalacticraft/Addon-API/issues"
10+
"homepage": "https://galacticraft.team/",
11+
"sources": "https://github.com/TeamGalacticraft/Addon-API/",
12+
"issues": "https://github.com/TeamGalacticraft/Addon-API/issues/"
1313
},
1414
"authors": [
1515
{
1616
"name": "Team Galacticraft",
1717
"contact": {
18-
"homepage": "https://github.com/TeamGalacticraft",
18+
"homepage": "https://github.com/TeamGalacticraft/",
1919
"discord": "https://discord.gg/n3QqhMYyFK"
2020
}
2121
}
2222
],
2323
"environment": "*",
2424
"entrypoints": {
25-
"main": [
26-
"dev.galacticraft.api.testmod.GCApiTestMod"
27-
]
25+
"fabric-gametest": [ "dev.galacticraft.api.gametest.GalacticraftApiTestSuite" ]
2826
},
2927
"depends": {
30-
"fabricloader": ">=0.10.0",
31-
"minecraft": ">=1.16.2",
32-
"galacticraft-api": ">=0.3"
33-
},
34-
"suggests": {
35-
"modmenu": "*",
36-
"galacticraft": "*"
28+
"fabricloader": ">=0.11.6",
29+
"minecraft": ">=1.17.1",
30+
"galacticraft-api": ">=0.4.0-prealpha.19+1.17.1"
3731
}
3832
}

src/main/java/dev/galacticraft/api/team/Role.java

Lines changed: 0 additions & 84 deletions
This file was deleted.

0 commit comments

Comments
 (0)