// Build script for each Minecraft version node (versions//). The root project itself // is configured by stonecutter.gradle.kts. plugins { // Applies the right Loom variant for the node's Minecraft version. id("dev.kikugie.loom-back-compat") `maven-publish` } // DO NOT set group = ...! (Stonecutter/loom-back-compat reads mod.group.) val modVersion = property("mod.version") as String version = "$modVersion+${sc.current.version}" base.archivesName = "emotes-fabric" val requiredJava: JavaVersion = when { sc.current.parsed >= "26.1" -> JavaVersion.VERSION_25 else -> JavaVersion.VERSION_21 } val testmod: SourceSet = sourceSets.create("testmod") { compileClasspath += sourceSets.main.get().compileClasspath + sourceSets.main.get().output runtimeClasspath += sourceSets.main.get().runtimeClasspath + sourceSets.main.get().output } loom { // The testmod's mod* configurations; 26.1+ has nothing to remap, and loomx aliases them there. if (!loomx.isUnobfuscated) createRemapConfigurations(testmod) mods { register("saturn_emotes") { sourceSet(sourceSets.main.get()) } register("saturn_emotes_testmod") { sourceSet(testmod) } } decompilerOptions.named("vineflower") { options.put("mark-corresponding-synthetics", "1") // Names lambdas, useful for mixins } runConfigs.all { preferGradleTask = true generateRunConfig = true runDirectory = rootProject.file("run") // Shared by every version jvmArguments.add("-Dmixin.debug.export=true") } runs { // ./gradlew ::runTestmodClient launches the game with the tester mod loaded. register("testmodClient") { client() name = "Testmod Client" source(testmod) } // ./gradlew ::runClientGameTest screenshots the test animations, then quits. register("clientGameTest") { client() name = "Client Game Test" source(testmod) vmArg("-Dfabric.client.gametest") runDir = "build/run/clientGameTest" } } } dependencies { fun fapi(vararg modules: String) { for (it in modules) modImplementation(fabricApi.module(it, sc.properties["deps.fabric_api"])) } minecraft("com.mojang:minecraft:${sc.current.version}") loomx.applyMojangMappings() modImplementation("net.fabricmc:fabric-loader:${property("deps.fabric_loader")}") fapi("fabric-api-base", "fabric-lifecycle-events-v1") // The core is Minecraft-independent; ship it inside the mod jar, with the Jackson it reads emotes // with (the version Saturn Client ships too, so the game only loads one). api(project(":core")) include(project(":core")) for (module in listOf("jackson-databind", "jackson-core", "jackson-annotations")) { include("com.fasterxml.jackson.core:$module:2.17.0") } for (module in listOf("fabric-command-api-v2", "fabric-client-gametest-api-v1")) { "modTestmodImplementation"(fabricApi.module(module, sc.properties["deps.fabric_api"])) } // Single modules don't bring their Fabric API dependencies (which differ between versions), // so the tester runs with all of Fabric API. "modTestmodRuntimeOnly"("net.fabricmc.fabric-api:fabric-api:${sc.properties.get("deps.fabric_api")}") } java { withSourcesJar() targetCompatibility = requiredJava sourceCompatibility = requiredJava toolchain.languageVersion = JavaLanguageVersion.of(requiredJava.majorVersion) } tasks { val props = mapOf( "id" to sc.properties["mod.id"], "name" to sc.properties["mod.name"], "version" to version.toString(), "minecraft" to sc.properties["mod.mc_compat"], "loader" to Regex("\\d+\\.\\d+").find(sc.properties.get("deps.fabric_loader"))!!.value, "java" to "JAVA_${requiredJava.majorVersion}", ) withType().configureEach { inputs.properties(props) filesMatching(listOf("fabric.mod.json", "*.mixins.json")) { expand(props) } } withType().configureEach { from(rootProject.file("LICENSE")) { rename { "${it}_saturn_emotes" } } } register("buildAndCollect") { group = "build" description = "Builds the mod jar and copies it to build/libs// in the root project" from(loomx.modJar.flatMap { it.archiveFile }) into(rootProject.layout.buildDirectory.dir("libs/$modVersion")) } } publishing { publications { create("maven") { groupId = property("mod.group") as String artifactId = "emotes-fabric" from(components["java"]) } } } apply(from = rootProject.file("gradle/gitea.gradle.kts"))