mirror of
https://github.com/SquidDev-CC/CC-Tweaked
synced 2025-03-29 14:56:58 +00:00

BYTECODE WAS NOT SUPPOSED TO BE REWRITTEN YEARS OF DEBUGGING REMAPPING FAILURES yet NO ACTUAL SOLUTION FOUND. Wanted to use Mixins for anyway for a laugh? We had a tool for that: it was called "FABRIC LOOM". "Yes, please produce completely broken jars for no discernable reason" Statements dreamed up by the utterly Deranged. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * This removes our two mixins used on Forge: - Breaking progress for cabled/wired modems. - Running client commands from chat click events. We now suggest the command on Forge instead. Occasionally we get issues where the mixin annotation processor doesn't write its tsrg file in time for the reobfJar/reobfJarJar task. I thought we'd fixed that cb8e06af2aefd931b1f6743849a7afb2a25ea0bd, but sometimes we still produce missing jars - I have a feeling this might be to do with incremental compilation. We can maybe re-evaluate this on 1.20.4, where we don't need to worry about remapping any more.
259 lines
7.7 KiB
Plaintext
259 lines
7.7 KiB
Plaintext
// SPDX-FileCopyrightText: 2022 The CC: Tweaked Developers
|
|
//
|
|
// SPDX-License-Identifier: MPL-2.0
|
|
|
|
import cc.tweaked.gradle.*
|
|
import net.minecraftforge.gradle.common.util.RunConfig
|
|
|
|
plugins {
|
|
id("cc-tweaked.forge")
|
|
id("cc-tweaked.gametest")
|
|
id("cc-tweaked.mod-publishing")
|
|
}
|
|
|
|
val modVersion: String by extra
|
|
|
|
val allProjects = listOf(":core-api", ":core", ":forge-api").map { evaluationDependsOn(it) }
|
|
cct {
|
|
inlineProject(":common")
|
|
allProjects.forEach { externalSources(it) }
|
|
}
|
|
|
|
sourceSets {
|
|
main {
|
|
resources.srcDir("src/generated/resources")
|
|
}
|
|
}
|
|
|
|
minecraft {
|
|
runs {
|
|
// configureEach would be better, but we need to eagerly configure configs or otherwise the run task doesn't
|
|
// get set up properly.
|
|
all {
|
|
property("forge.logging.markers", "REGISTRIES")
|
|
property("forge.logging.console.level", "debug")
|
|
|
|
mods.register("computercraft") {
|
|
cct.sourceDirectories.get().forEach {
|
|
if (it.classes) sources(it.sourceSet)
|
|
}
|
|
}
|
|
}
|
|
|
|
val client by registering {
|
|
workingDirectory(file("run"))
|
|
}
|
|
|
|
val server by registering {
|
|
workingDirectory(file("run/server"))
|
|
arg("--nogui")
|
|
}
|
|
|
|
val data by registering {
|
|
workingDirectory(file("run"))
|
|
args(
|
|
"--mod", "computercraft", "--all",
|
|
"--output", file("src/generated/resources/"),
|
|
"--existing", project(":common").file("src/main/resources/"),
|
|
"--existing", file("src/main/resources/"),
|
|
)
|
|
}
|
|
|
|
fun RunConfig.configureForGameTest() {
|
|
val old = lazyTokens["minecraft_classpath"]
|
|
lazyToken("minecraft_classpath") {
|
|
// Add all files in testMinecraftLibrary to the classpath.
|
|
val allFiles = mutableSetOf<String>()
|
|
|
|
val oldVal = old?.get()
|
|
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)
|
|
|
|
arg("--mixin.config=computercraft-gametest.mixins.json")
|
|
|
|
mods.register("cctest") {
|
|
source(sourceSets["testMod"])
|
|
source(sourceSets["testFixtures"])
|
|
source(project(":core").sourceSets["testFixtures"])
|
|
}
|
|
}
|
|
|
|
val testClient by registering {
|
|
workingDirectory(file("run/testClient"))
|
|
parent(client.get())
|
|
configureForGameTest()
|
|
|
|
property("cctest.tags", "client,common")
|
|
}
|
|
|
|
val gameTestServer by registering {
|
|
workingDirectory(file("run/testServer"))
|
|
configureForGameTest()
|
|
|
|
property("forge.logging.console.level", "info")
|
|
jvmArg("-ea")
|
|
}
|
|
}
|
|
}
|
|
|
|
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 {
|
|
compileOnly(libs.jetbrainsAnnotations)
|
|
annotationProcessorEverywhere(libs.autoService)
|
|
|
|
clientCompileOnly(variantOf(libs.emi) { classifier("api") })
|
|
libs.bundles.externalMods.forge.compile.get().map { compileOnly(fg.deobf(it)) }
|
|
libs.bundles.externalMods.forge.runtime.get().map { runtimeOnly(fg.deobf(it)) }
|
|
|
|
// Depend on our other projects.
|
|
api(commonClasses(project(":forge-api"))) { cct.exclude(this) }
|
|
clientApi(clientClasses(project(":forge-api"))) { cct.exclude(this) }
|
|
implementation(project(":core")) { cct.exclude(this) }
|
|
|
|
minecraftEmbed(libs.cobalt) {
|
|
val version = libs.versions.cobalt.get()
|
|
jarJar.ranged(this, "[$version,${getNextVersion(version)})")
|
|
}
|
|
minecraftEmbed(libs.jzlib) {
|
|
jarJar.ranged(this, "[${libs.versions.jzlib.get()},)")
|
|
}
|
|
minecraftEmbed(libs.netty.http) {
|
|
jarJar.ranged(this, "[${libs.versions.netty.get()},)")
|
|
isTransitive = false
|
|
}
|
|
minecraftEmbed(libs.netty.socks) {
|
|
jarJar.ranged(this, "[${libs.versions.netty.get()},)")
|
|
isTransitive = false
|
|
}
|
|
minecraftEmbed(libs.netty.proxy) {
|
|
jarJar.ranged(this, "[${libs.versions.netty.get()},)")
|
|
isTransitive = false
|
|
}
|
|
|
|
testFixturesApi(libs.bundles.test)
|
|
testFixturesApi(libs.bundles.kotlin)
|
|
|
|
testImplementation(testFixtures(project(":core")))
|
|
testImplementation(libs.bundles.test)
|
|
testRuntimeOnly(libs.bundles.testRuntime)
|
|
|
|
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")))
|
|
}
|
|
|
|
// Compile tasks
|
|
|
|
tasks.processResources {
|
|
inputs.property("modVersion", modVersion)
|
|
inputs.property("forgeVersion", libs.versions.forge.get())
|
|
|
|
filesMatching("META-INF/mods.toml") {
|
|
expand(mapOf("forgeVersion" to libs.versions.forge.get(), "file" to mapOf("jarVersion" to modVersion)))
|
|
}
|
|
}
|
|
|
|
tasks.jar {
|
|
finalizedBy("reobfJar")
|
|
archiveClassifier.set("slim")
|
|
|
|
for (source in cct.sourceDirectories.get()) {
|
|
if (source.classes && source.external) from(source.sourceSet.output)
|
|
}
|
|
}
|
|
|
|
tasks.sourcesJar {
|
|
for (source in cct.sourceDirectories.get()) from(source.sourceSet.allSource)
|
|
}
|
|
|
|
tasks.jarJar {
|
|
finalizedBy("reobfJarJar")
|
|
archiveClassifier.set("")
|
|
|
|
for (source in cct.sourceDirectories.get()) {
|
|
if (source.classes) from(source.sourceSet.output)
|
|
}
|
|
}
|
|
|
|
tasks.assemble { dependsOn("jarJar") }
|
|
|
|
// Check tasks
|
|
|
|
tasks.test {
|
|
systemProperty("cct.test-files", layout.buildDirectory.dir("tmp/testFiles").getAbsolutePath())
|
|
}
|
|
|
|
val runGametest by tasks.registering(JavaExec::class) {
|
|
group = LifecycleBasePlugin.VERIFICATION_GROUP
|
|
description = "Runs tests on a temporary Minecraft instance."
|
|
dependsOn("cleanRunGametest")
|
|
usesService(MinecraftRunnerService.get(gradle))
|
|
|
|
setRunConfig(minecraft.runs["gameTestServer"])
|
|
|
|
systemProperty("cctest.gametest-report", layout.buildDirectory.dir("test-results/$name.xml").getAbsolutePath())
|
|
}
|
|
cct.jacoco(runGametest)
|
|
tasks.check { dependsOn(runGametest) }
|
|
|
|
val runGametestClient by tasks.registering(ClientJavaExec::class) {
|
|
description = "Runs client-side gametests with no mods"
|
|
setRunConfig(minecraft.runs["testClient"])
|
|
tags("client")
|
|
}
|
|
cct.jacoco(runGametestClient)
|
|
|
|
tasks.register("checkClient") {
|
|
group = LifecycleBasePlugin.VERIFICATION_GROUP
|
|
description = "Runs all client-only checks."
|
|
dependsOn(runGametestClient)
|
|
}
|
|
|
|
// Upload tasks
|
|
|
|
modPublishing {
|
|
output.set(tasks.jarJar)
|
|
}
|
|
|
|
// Don't publish the slim jar
|
|
for (cfg in listOf(configurations.apiElements, configurations.runtimeElements)) {
|
|
cfg.configure { artifacts.removeIf { it.classifier == "slim" } }
|
|
}
|
|
|
|
publishing {
|
|
publications {
|
|
named("maven", MavenPublication::class) {
|
|
fg.component(this)
|
|
// jarJar.component is broken (https://github.com/MinecraftForge/ForgeGradle/issues/914), so declare the
|
|
// artifact explicitly.
|
|
artifact(tasks.jarJar)
|
|
|
|
mavenDependencies {
|
|
cct.configureExcludes(this)
|
|
exclude(libs.jei.forge.get())
|
|
}
|
|
}
|
|
}
|
|
}
|