2023-03-15 21:52:13 +00:00
|
|
|
// SPDX-FileCopyrightText: 2022 The CC: Tweaked Developers
|
|
|
|
//
|
|
|
|
// SPDX-License-Identifier: MPL-2.0
|
|
|
|
|
2022-11-18 23:57:25 +00:00
|
|
|
import cc.tweaked.gradle.*
|
2022-11-10 19:32:13 +00:00
|
|
|
import net.fabricmc.loom.configuration.ide.RunConfigSettings
|
2022-11-18 23:57:25 +00:00
|
|
|
import java.util.*
|
2022-11-10 19:32:13 +00:00
|
|
|
|
|
|
|
plugins {
|
|
|
|
id("cc-tweaked.fabric")
|
|
|
|
id("cc-tweaked.gametest")
|
2023-03-15 23:20:07 +00:00
|
|
|
id("cc-tweaked.mod-publishing")
|
2022-11-10 19:32:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
val modVersion: String by extra
|
|
|
|
|
|
|
|
val allProjects = listOf(":core-api", ":core", ":fabric-api").map { evaluationDependsOn(it) }
|
|
|
|
cct {
|
|
|
|
inlineProject(":common")
|
|
|
|
allProjects.forEach { externalSources(it) }
|
|
|
|
}
|
|
|
|
|
2022-11-18 23:57:25 +00:00
|
|
|
fun addRemappedConfiguration(name: String) {
|
2023-06-29 19:10:17 +00:00
|
|
|
// There was a regression in Loom 1.1 which means that targetConfigurationName doesn't do anything, and remap
|
|
|
|
// configurations just get added to the main source set (https://github.com/FabricMC/fabric-loom/issues/843).
|
|
|
|
// To get around that, we create our own source set and register a remap configuration with that. This does
|
|
|
|
// introduce a bit of noise, but it's not the end of the world.
|
|
|
|
val ourSourceSet = sourceSets.register(name) {
|
|
|
|
// Try to make this source set as much of a non-entity as possible.
|
|
|
|
listOf(allSource, java, resources, kotlin).forEach { it.setSrcDirs(emptyList<File>()) }
|
2022-11-18 23:57:25 +00:00
|
|
|
}
|
2023-06-29 19:10:17 +00:00
|
|
|
val capitalName = name.replaceFirstChar { it.titlecase(Locale.ROOT) }
|
2022-11-18 23:57:25 +00:00
|
|
|
loom.addRemapConfiguration("mod$capitalName") {
|
|
|
|
onCompileClasspath.set(false)
|
2023-06-29 19:10:17 +00:00
|
|
|
onRuntimeClasspath.set(true)
|
|
|
|
sourceSet.set(ourSourceSet)
|
2022-11-18 23:57:25 +00:00
|
|
|
targetConfigurationName.set(name)
|
|
|
|
}
|
2023-06-29 19:10:17 +00:00
|
|
|
configurations.create(name) {
|
|
|
|
isCanBeConsumed = false
|
|
|
|
isCanBeResolved = true
|
|
|
|
extendsFrom(configurations["${name}RuntimeClasspath"])
|
|
|
|
}
|
2022-11-18 23:57:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
addRemappedConfiguration("testWithSodium")
|
|
|
|
addRemappedConfiguration("testWithIris")
|
|
|
|
|
2024-01-03 21:05:03 +00:00
|
|
|
configurations {
|
|
|
|
// Declare some configurations which are both included (jar-in-jar-ed) and a normal dependency (so they appear in
|
|
|
|
// our POM).
|
|
|
|
val includeRuntimeOnly by registering {
|
|
|
|
isCanBeConsumed = false
|
|
|
|
isCanBeResolved = false
|
|
|
|
}
|
|
|
|
val includeImplementation by registering {
|
|
|
|
isCanBeConsumed = false
|
|
|
|
isCanBeResolved = false
|
|
|
|
}
|
|
|
|
|
|
|
|
include { extendsFrom(includeRuntimeOnly.get(), includeImplementation.get()) }
|
|
|
|
runtimeOnly { extendsFrom(includeRuntimeOnly.get()) }
|
|
|
|
implementation { extendsFrom(includeImplementation.get()) }
|
|
|
|
}
|
|
|
|
|
2022-11-10 19:32:13 +00:00
|
|
|
dependencies {
|
2023-07-10 19:31:06 +00:00
|
|
|
clientCompileOnly(variantOf(libs.emi) { classifier("api") })
|
2022-11-10 19:32:13 +00:00
|
|
|
modCompileOnly(libs.bundles.externalMods.fabric.compile) {
|
|
|
|
exclude("net.fabricmc", "fabric-loader")
|
|
|
|
exclude("net.fabricmc.fabric-api")
|
|
|
|
}
|
2023-06-08 08:48:37 +00:00
|
|
|
|
2022-11-10 19:32:13 +00:00
|
|
|
modClientRuntimeOnly(libs.bundles.externalMods.fabric.runtime) {
|
|
|
|
exclude("net.fabricmc", "fabric-loader")
|
|
|
|
exclude("net.fabricmc.fabric-api")
|
|
|
|
}
|
|
|
|
|
2022-11-18 23:57:25 +00:00
|
|
|
"modTestWithSodium"(libs.sodium)
|
|
|
|
"modTestWithIris"(libs.iris)
|
|
|
|
"modTestWithIris"(libs.sodium)
|
|
|
|
|
2024-01-03 21:05:03 +00:00
|
|
|
"includeRuntimeOnly"(libs.cobalt)
|
|
|
|
"includeRuntimeOnly"(libs.jzlib)
|
|
|
|
"includeRuntimeOnly"(libs.netty.http)
|
|
|
|
"includeRuntimeOnly"(libs.netty.socks)
|
|
|
|
"includeRuntimeOnly"(libs.netty.proxy)
|
|
|
|
|
|
|
|
"includeImplementation"(libs.nightConfig.core)
|
|
|
|
"includeImplementation"(libs.nightConfig.toml)
|
2022-11-10 19:32:13 +00:00
|
|
|
|
|
|
|
// Pull in our other projects. See comments in MinecraftConfigurations on this nastiness.
|
2023-12-16 22:35:11 +00:00
|
|
|
api(commonClasses(project(":fabric-api"))) { cct.exclude(this) }
|
|
|
|
clientApi(clientClasses(project(":fabric-api"))) { cct.exclude(this) }
|
|
|
|
implementation(project(":core")) { cct.exclude(this) }
|
2022-11-17 09:26:57 +00:00
|
|
|
|
2022-11-10 19:32:13 +00:00
|
|
|
annotationProcessorEverywhere(libs.autoService)
|
|
|
|
|
|
|
|
testModImplementation(testFixtures(project(":core")))
|
|
|
|
testModImplementation(testFixtures(project(":fabric")))
|
|
|
|
|
|
|
|
testImplementation(libs.bundles.test)
|
|
|
|
testRuntimeOnly(libs.bundles.testRuntime)
|
2023-10-26 21:06:40 +00:00
|
|
|
testRuntimeOnly(libs.fabric.junit)
|
2023-10-08 14:21:33 +00:00
|
|
|
|
|
|
|
testFixturesImplementation(testFixtures(project(":core")))
|
2022-11-10 19:32:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
sourceSets.main { resources.srcDir("src/generated/resources") }
|
|
|
|
|
|
|
|
loom {
|
|
|
|
accessWidenerPath.set(project(":common").file("src/main/resources/computercraft.accesswidener"))
|
|
|
|
mixin.defaultRefmapName.set("computercraft.refmap.json")
|
|
|
|
|
|
|
|
mods {
|
|
|
|
register("computercraft") {
|
|
|
|
// Configure sources when running via the IDE. Note these don't add build dependencies (hence why it's safe
|
|
|
|
// to use common), only change how the launch.cfg file is generated.
|
|
|
|
cct.sourceDirectories.get().forEach { sourceSet(it.sourceSet) }
|
|
|
|
|
|
|
|
// Running via Gradle
|
|
|
|
dependency(dependencies.project(":core").apply { isTransitive = false })
|
|
|
|
}
|
|
|
|
|
|
|
|
register("cctest") {
|
|
|
|
sourceSet(sourceSets.testMod.get())
|
|
|
|
sourceSet(project(":common").sourceSets.testMod.get())
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
runs {
|
|
|
|
configureEach {
|
|
|
|
ideConfigGenerated(true)
|
|
|
|
}
|
|
|
|
|
|
|
|
named("client") {
|
|
|
|
configName = "Client"
|
|
|
|
}
|
|
|
|
|
|
|
|
named("server") {
|
|
|
|
configName = "Server"
|
|
|
|
runDir("run/server")
|
|
|
|
}
|
|
|
|
|
|
|
|
register("data") {
|
|
|
|
configName = "Datagen"
|
2023-06-17 09:46:34 +00:00
|
|
|
client()
|
2022-11-10 19:32:13 +00:00
|
|
|
|
|
|
|
runDir("run/dataGen")
|
|
|
|
property("fabric-api.datagen")
|
|
|
|
property("fabric-api.datagen.output-dir", file("src/generated/resources").absolutePath)
|
|
|
|
property("fabric-api.datagen.strict-validation")
|
|
|
|
}
|
|
|
|
|
|
|
|
fun configureForGameTest(config: RunConfigSettings) = config.run {
|
|
|
|
source(sourceSets.testMod.get())
|
|
|
|
|
|
|
|
val testSources = project(":common").file("src/testMod/resources/data/cctest").absolutePath
|
|
|
|
property("cctest.sources", testSources)
|
|
|
|
|
|
|
|
// Load cctest last, so it can override resources. This bypasses Fabric's shuffling of mods
|
|
|
|
property("fabric.debug.loadLate", "cctest")
|
Ensure the terminal exists when creating a monitor peripheral
Previously we had the invariant that if we had a server monitor, we also
had a terminal. When a monitor shrank into a place, we deleted the
monitor, and then recreated it when a peripheral was requested.
As of ab785a090698e6972caac95691393428c6f8370b this has changed
slightly, and we now just delete the terminal (keeping the ServerMonitor
around). However, we didn't adjust the peripheral code accordingly,
meaning we didn't recreate the /terminal/ when a peripheral was
requested.
The fix for this is very simple - most of the rest of this commit is
some additional code for ensuring monitor invariants hold, so we can
write tests with a little more confidence.
I'm not 100% sold on this approach. It's tricky having a double layer of
nullable state (ServerMonitor, and then the terminal). However, I think
this is reasonable - the ServerMonitor is a reference to the multiblock,
and the Terminal is part of the multiblock's state.
Even after all the refactors, monitor code is still nastier than I'd
like :/.
Fixes #1608
2023-10-09 21:03:43 +00:00
|
|
|
|
|
|
|
vmArg("-ea")
|
2022-11-10 19:32:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
val testClient by registering {
|
|
|
|
configName = "Test Client"
|
|
|
|
client()
|
|
|
|
configureForGameTest(this)
|
|
|
|
|
|
|
|
runDir("run/testClient")
|
2022-11-18 23:57:25 +00:00
|
|
|
property("cctest.tags", "client,common")
|
2022-11-10 19:32:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
register("gametest") {
|
|
|
|
configName = "Game Test"
|
|
|
|
server()
|
|
|
|
configureForGameTest(this)
|
|
|
|
|
|
|
|
property("fabric-api.gametest")
|
2023-12-16 22:35:11 +00:00
|
|
|
property(
|
|
|
|
"fabric-api.gametest.report-file",
|
|
|
|
layout.buildDirectory.dir("test-results/runGametest.xml")
|
|
|
|
.getAbsolutePath(),
|
|
|
|
)
|
2022-11-10 19:32:13 +00:00
|
|
|
runDir("run/gametest")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
tasks.processResources {
|
|
|
|
inputs.property("version", modVersion)
|
|
|
|
|
|
|
|
filesMatching("fabric.mod.json") {
|
|
|
|
expand(mapOf("version" to modVersion))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
tasks.jar {
|
2022-11-17 09:26:57 +00:00
|
|
|
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)
|
2022-11-10 19:32:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
val validateMixinNames by tasks.registering(net.fabricmc.loom.task.ValidateMixinNameTask::class) {
|
|
|
|
source(sourceSets.main.get().output)
|
|
|
|
source(sourceSets.client.get().output)
|
|
|
|
source(sourceSets.testMod.get().output)
|
|
|
|
}
|
2022-11-18 23:57:25 +00:00
|
|
|
tasks.check { dependsOn(validateMixinNames) }
|
2022-11-10 19:32:13 +00:00
|
|
|
|
|
|
|
tasks.test { dependsOn(tasks.generateDLIConfig) }
|
|
|
|
|
2022-11-18 23:57:25 +00:00
|
|
|
val runGametest = tasks.named<JavaExec>("runGametest") {
|
|
|
|
usesService(MinecraftRunnerService.get(gradle))
|
|
|
|
}
|
2022-11-10 19:32:13 +00:00
|
|
|
cct.jacoco(runGametest)
|
2022-11-18 23:57:25 +00:00
|
|
|
tasks.check { dependsOn(runGametest) }
|
|
|
|
|
|
|
|
val runGametestClient by tasks.registering(ClientJavaExec::class) {
|
|
|
|
description = "Runs client-side gametests with no mods"
|
|
|
|
copyFrom("runTestClient")
|
|
|
|
|
|
|
|
tags("client")
|
|
|
|
}
|
|
|
|
cct.jacoco(runGametestClient)
|
2022-11-10 19:32:13 +00:00
|
|
|
|
2022-11-18 23:57:25 +00:00
|
|
|
val runGametestClientWithSodium by tasks.registering(ClientJavaExec::class) {
|
|
|
|
description = "Runs client-side gametests with Sodium"
|
|
|
|
copyFrom("runTestClient")
|
|
|
|
|
|
|
|
tags("sodium")
|
|
|
|
classpath += configurations["testWithSodium"]
|
|
|
|
}
|
|
|
|
cct.jacoco(runGametestClientWithSodium)
|
|
|
|
|
|
|
|
val runGametestClientWithIris by tasks.registering(ClientJavaExec::class) {
|
|
|
|
description = "Runs client-side gametests with Iris"
|
|
|
|
copyFrom("runTestClient")
|
|
|
|
|
|
|
|
tags("iris")
|
|
|
|
classpath += configurations["testWithIris"]
|
|
|
|
|
|
|
|
withFileFrom(workingDir.resolve("shaderpacks/ComplementaryShaders_v4.6.zip")) {
|
|
|
|
cct.downloadFile("Complementary Shaders", "https://edge.forgecdn.net/files/3951/170/ComplementaryShaders_v4.6.zip")
|
|
|
|
}
|
|
|
|
withFileContents(workingDir.resolve("config/iris.properties")) {
|
|
|
|
"""
|
|
|
|
enableShaders=true
|
|
|
|
shaderPack=ComplementaryShaders_v4.6.zip
|
|
|
|
""".trimIndent()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
cct.jacoco(runGametestClientWithIris)
|
|
|
|
|
|
|
|
tasks.register("checkClient") {
|
|
|
|
group = LifecycleBasePlugin.VERIFICATION_GROUP
|
|
|
|
description = "Runs all client-only checks."
|
|
|
|
dependsOn(runGametestClient, runGametestClientWithSodium, runGametestClientWithIris)
|
|
|
|
}
|
2022-11-17 09:26:57 +00:00
|
|
|
|
2023-03-15 23:20:07 +00:00
|
|
|
modPublishing {
|
|
|
|
output.set(tasks.remapJar)
|
|
|
|
}
|
|
|
|
|
2022-11-17 09:26:57 +00:00
|
|
|
tasks.withType(GenerateModuleMetadata::class).configureEach { isEnabled = false }
|
|
|
|
publishing {
|
|
|
|
publications {
|
|
|
|
named("maven", MavenPublication::class) {
|
|
|
|
mavenDependencies {
|
2023-12-16 22:35:11 +00:00
|
|
|
cct.configureExcludes(this)
|
2022-11-17 09:26:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2023-06-10 07:55:07 +00:00
|
|
|
|
|
|
|
modrinth {
|
|
|
|
required.project("fabric-api")
|
|
|
|
}
|