Build with loom-back-compat and a Java toolchain per version

Prepares the build for 26.x, which ships unobfuscated and needs Java 25
(#39):

- loom-back-compat applies the remapping Loom to 1.21.x and would apply
  the plain one to 26.x. loom_version becomes loomx.loom_version.
- Each version compiles with its Java toolchain (21 for 1.21.x, 25 for
  26.x), and the mixin configs take their compatibility level from it.
  The foojay resolver downloads a missing JDK; CI installs 21 and 25.
- buildAll collects remapJar's output, or jar's where there's nothing
  to remap.
- fabric.mod.json depends on fabric-api, Fabric API's mod id; 26.x's
  jar no longer provides the old "fabric" alias.

Nothing changes for the 1.21.x jars.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
2026-09-30 19:15:02 +02:00
co-authored by claude
parent 950a83c48d
commit b018db1851
10 changed files with 52 additions and 32 deletions
+10 -7
View File
@@ -1,11 +1,14 @@
// Builds one Minecraft version from the shared src/. Stonecutter runs this for each version in
// stonecutterVersions (settings.gradle.kts), with that version's versions/<v>/gradle.properties.
plugins {
id("net.fabricmc.fabric-loom-remap")
id("dev.kikugie.loom-back-compat")
`maven-publish`
}
val minecraftVersion = property("minecraft_version") as String
// The Minecraft versions the jar loads on (fabric.mod.json); a range where hotfixes share a jar.
val minecraftCompat = findProperty("minecraft_compat") as String? ?: minecraftVersion
val javaVersion = if (sc.current.parsed >= "26.1") 25 else 21
val loaderVersion = property("loader_version") as String
version = "${property("mod_version")}+$minecraftVersion"
@@ -17,7 +20,7 @@ base {
dependencies {
minecraft("com.mojang:minecraft:$minecraftVersion")
mappings(loom.officialMojangMappings())
loomx.applyMojangMappings()
modImplementation("net.fabricmc:fabric-loader:$loaderVersion")
modImplementation("net.fabricmc.fabric-api:fabric-api:${property("fabric_api_version")}")
@@ -42,23 +45,23 @@ dependencies {
tasks.processResources {
val values = mapOf(
"version" to project.version.toString(),
"minecraft_version" to minecraftVersion,
"minecraft_version" to minecraftCompat,
"loader_version" to loaderVersion,
"java" to "JAVA_$javaVersion",
)
inputs.properties(values)
filteringCharset = "UTF-8"
filesMatching("fabric.mod.json") { expand(values) }
filesMatching(listOf("fabric.mod.json", "*.mixins.json")) { expand(values) }
}
tasks.withType<JavaCompile>().configureEach {
options.release = 21
options.release = javaVersion
}
java {
// Loom attaches the sources jar to remapSourcesJar and build.
withSourcesJar()
sourceCompatibility = JavaVersion.VERSION_21
targetCompatibility = JavaVersion.VERSION_21
toolchain.languageVersion = JavaLanguageVersion.of(javaVersion)
}
tasks.jar {