- fix: NullPointerException when the config class of mod updated

- alter: better test code in `common/src/test`, `neoforge/src/test` and `fabric/src/test`, run `Test Minecraft Client(:fabric)` or `Test Minecraft Client(:neoforge)` for testing
This commit is contained in:
Jaffe2718
2025-09-11 11:48:26 +08:00
parent 78c462dc1c
commit c775a9d221
18 changed files with 167 additions and 62 deletions

View File

@@ -13,11 +13,44 @@ repositories {
architectury {
platformSetupLoomIde()
neoForge()
neoForge {
platformPackage = "neoforge"
}
}
sourceSets {
test {
compileClasspath += main.compileClasspath
runtimeClasspath += main.runtimeClasspath
java {
srcDirs.add('src/test/java' as File)
}
resources {
srcDirs.add('src/test/resources' as File)
}
}
}
loom {
accessWidenerPath = project(":common").loom.accessWidenerPath
runs {
testClient {
client()
name = "Test Minecraft Client"
mods {
create('midnightlib') {
sourceSet sourceSets.main
}
create('modid') { // test mod
sourceSet sourceSets.test
}
}
source sourceSets.test
}
}
}
configurations {
@@ -44,6 +77,10 @@ dependencies {
common(project(path: ':common', configuration: 'namedElements')) { transitive false }
shadowBundle project(path: ':common', configuration: 'transformProductionNeoForge')
// testImplementation common(project(path: ':common', configuration: 'namedElements')) { transitive false }
testImplementation common(project(path: ':common', configuration: 'testOutput')) { transitive false }
testImplementation sourceSets.main.output
}
processResources {
@@ -54,6 +91,14 @@ processResources {
}
}
processTestResources {
inputs.property 'version', rootProject.version
filesMatching('META-INF/neoforge.mods.toml') {
expand version: rootProject.version
}
}
shadowJar {
configurations = [project.configurations.shadowBundle]
archiveClassifier = 'dev-shadow'
@@ -105,4 +150,4 @@ unifiedPublishing {
}
}
}
}
}