mirror of
https://github.com/SquidDev-CC/CC-Tweaked
synced 2025-01-25 00:16:54 +00:00
Change how we put test libraries on the class path
- Mark our core test-fixtures jar as part of the "cctest", rather than a separate library. I'm fairly sure this was actually using the classpath version of CC rather than the legacyClasspath version! - Add a new "testMinecraftLibrary" configuration, instead of trying to infer it from the classpath. We have to jump through some hoops to avoid having multiple versions of a library on the classpath at once, but it's not too bad. I'm working on a patch to bsl which might allow us to kill of legacyClasspath instead. Please, anything is better than this.
This commit is contained in:
parent
57b1a65db3
commit
ebeaa757a9
@ -50,13 +50,6 @@ tasks.test {
|
||||
systemProperty("cct.test-files", layout.buildDirectory.dir("tmp/testFiles").getAbsolutePath())
|
||||
}
|
||||
|
||||
tasks.testFixturesJar {
|
||||
manifest {
|
||||
// Ensure the test fixtures jar loads as a mod. Thanks FML >_>.
|
||||
attributes("FMLModType" to "GAMELIBRARY")
|
||||
}
|
||||
}
|
||||
|
||||
val checkChangelog by tasks.registering(cc.tweaked.gradle.CheckChangelog::class) {
|
||||
version.set(modVersion)
|
||||
whatsNew.set(file("src/main/resources/data/computercraft/lua/rom/help/whatsnew.md"))
|
||||
|
@ -63,18 +63,15 @@ minecraft {
|
||||
fun RunConfig.configureForGameTest() {
|
||||
val old = lazyTokens["minecraft_classpath"]
|
||||
lazyToken("minecraft_classpath") {
|
||||
// We do some terrible hacks here to basically find all things not already on the runtime classpath
|
||||
// and add them. /Except/ for our source sets, as those need to load inside the Minecraft classpath.
|
||||
val testMod = configurations["testModRuntimeClasspath"].resolve()
|
||||
val implementation = configurations.runtimeClasspath.get().resolve()
|
||||
val new = (testMod - implementation)
|
||||
.asSequence()
|
||||
.filter { it.isFile && !it.name.endsWith("-test-fixtures.jar") }
|
||||
.map { it.absolutePath }
|
||||
.joinToString(File.pathSeparator)
|
||||
// Add all files in testMinecraftLibrary to the classpath.
|
||||
val allFiles = mutableSetOf<String>()
|
||||
|
||||
val oldVal = old?.get()
|
||||
if (oldVal.isNullOrEmpty()) new else oldVal + File.pathSeparator + new
|
||||
if (!oldVal.isNullOrEmpty()) allFiles.addAll(oldVal.split(File.pathSeparatorChar))
|
||||
|
||||
for (file in configurations["testMinecraftLibrary"].resolve()) allFiles.add(file.absolutePath)
|
||||
|
||||
allFiles.joinToString(File.pathSeparator)
|
||||
}
|
||||
|
||||
property("cctest.sources", project(":common").file("src/testMod/resources/data/cctest").absolutePath)
|
||||
@ -84,6 +81,7 @@ minecraft {
|
||||
mods.register("cctest") {
|
||||
source(sourceSets["testMod"])
|
||||
source(sourceSets["testFixtures"])
|
||||
source(project(":core").sourceSets["testFixtures"])
|
||||
}
|
||||
}
|
||||
|
||||
@ -113,6 +111,13 @@ mixin {
|
||||
|
||||
configurations {
|
||||
minecraftLibrary { extendsFrom(minecraftEmbed.get()) }
|
||||
|
||||
val testMinecraftLibrary by registering {
|
||||
isCanBeResolved = true
|
||||
isCanBeConsumed = false
|
||||
// Prevent ending up with multiple versions of libraries on the classpath.
|
||||
shouldResolveConsistentlyWith(minecraftLibrary.get())
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
@ -161,6 +166,10 @@ dependencies {
|
||||
testModImplementation(testFixtures(project(":core")))
|
||||
testModImplementation(testFixtures(project(":forge")))
|
||||
|
||||
// Ensure our test fixture dependencies are on the classpath
|
||||
"testMinecraftLibrary"(libs.bundles.kotlin)
|
||||
"testMinecraftLibrary"(libs.bundles.test)
|
||||
|
||||
testFixturesImplementation(testFixtures(project(":core")))
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user