[build] Setup project for cross-version Minecraft development

This commit is contained in:
2025-10-26 12:52:04 +01:00
parent 1fbc97866c
commit d3f7aba2c9
18 changed files with 200 additions and 21 deletions

View File

@@ -1,7 +1,13 @@
import dev.panuszewski.gradle.pluginMarker
plugins {
`kotlin-dsl`
}
group = "de.siphalor.tweed5"
dependencies {
implementation(project(":helpers"))
implementation(pluginMarker(libs.plugins.lombok))
implementation(pluginMarker(libs.plugins.shadow))
}

View File

@@ -2,6 +2,10 @@ plugins {
id("dev.panuszewski.typesafe-conventions") version "0.9.0"
}
typesafeConventions {
autoPluginDependencies = false
}
dependencyResolutionManagement {
repositories {
gradlePluginPortal()

View File

@@ -2,7 +2,7 @@ plugins {
java
`java-library`
jacoco
alias(libs.plugins.lombok)
id("io.freefair.lombok")
id("de.siphalor.tweed5.publishing")
id("de.siphalor.tweed5.local-runtime-only")
id("de.siphalor.tweed5.expanded-sources-jar")

View File

@@ -3,7 +3,7 @@ import io.freefair.gradle.plugins.lombok.tasks.Delombok
plugins {
java
`java-library`
alias(libs.plugins.lombok)
id("io.freefair.lombok")
}
val expandedSourcesElements = configurations.consumable("expandedSourcesElements") {

View File

@@ -1,8 +1,8 @@
plugins {
`maven-publish`
alias(libs.plugins.shadow)
id("com.gradleup.shadow")
java
`java-library`
id("de.siphalor.tweed5.publishing")
id("de.siphalor.tweed5.minecraft.mod.component")
}
@@ -32,16 +32,3 @@ val minecraftModSourcesJar = tasks.register<Jar>("minecraftModSourcesJar") {
artifacts.add("minecraftModElements", minecraftModJar)
artifacts.add("minecraftModSourcesElements", minecraftModSourcesJar)
publishing {
publications {
create<MavenPublication>("minecraftMod") {
groupId = "${project.group}.minecraft"
artifactId = project.name
version = project.version.toString()
from(components["minecraftMod"])
}
}
}

View File

@@ -1,4 +1,6 @@
plugins {
`maven-publish`
id("de.siphalor.tweed5.publishing")
id("de.siphalor.tweed5.minecraft.mod.base")
}
@@ -27,3 +29,16 @@ tasks.named<Jar>("minecraftModSourcesJar") {
from(project.layout.buildDirectory.dir("minecraftModResources"))
dependsOn(processMinecraftModResources)
}
publishing {
publications {
create<MavenPublication>("minecraftMod") {
groupId = "${project.group}.minecraft"
artifactId = project.name
version = project.version.toString()
from(components["minecraftMod"])
}
}
}

View File

@@ -1,7 +1,7 @@
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
plugins {
alias(libs.plugins.shadow)
id("com.gradleup.shadow")
}
val shadowOnlyConfiguration = configurations.dependencyScope("shadowOnly")

View File

@@ -1,6 +1,6 @@
plugins {
java
alias(libs.plugins.lombok)
id("io.freefair.lombok")
}
dependencies {

View File

@@ -1,5 +1,4 @@
plugins {
id("de.siphalor.tweed5.publishing")
id("de.siphalor.tweed5.minecraft.mod.dummy")
}

View File

@@ -0,0 +1,8 @@
plugins {
id("de.siphalor.tweed5.expanded-sources-jar")
id("de.siphalor.tweed5.minecraft.mod.cross-version")
}
dependencies {
modImplementation(mcLibs.coat)
}

View File

@@ -0,0 +1,11 @@
import dev.panuszewski.gradle.pluginMarker
plugins {
`kotlin-dsl`
}
dependencies {
implementation("de.siphalor.tweed5:tweed5-conventions")
implementation(pluginMarker(mcCommonLibs.plugins.fabric.loom))
implementation(pluginMarker(mcCommonLibs.plugins.jcyo))
}

View File

@@ -0,0 +1,37 @@
plugins {
id("dev.panuszewski.typesafe-conventions") version "0.9.0"
}
typesafeConventions {
autoPluginDependencies = false
}
dependencyResolutionManagement {
repositories {
gradlePluginPortal()
maven {
name = "Siphalor"
url = uri("https://maven.siphalor.de")
mavenContent {
includeGroupAndSubgroups("de.siphalor")
}
}
maven {
name = "FabricMC"
url = uri("https://maven.fabricmc.net")
mavenContent {
includeGroupAndSubgroups("net.fabricmc")
includeGroup("fabric-loom")
}
}
}
versionCatalogs {
create("libs") {
from(files("../../gradle/libs.versions.toml"))
}
}
}
includeBuild("../../conventions")
rootProject.name = "tweed5-minecraft-conventions"

View File

@@ -0,0 +1,63 @@
import java.util.Properties
plugins {
id("fabric-loom")
id("de.siphalor.jcyo")
id("de.siphalor.tweed5.minecraft.mod.base")
}
val minecraftVersionDescriptor = project.property("minecraft.version.descriptor") as String
val mcProps = Properties().apply {
val propFile = project.layout.settingsDirectory.file("gradle/mc-$minecraftVersionDescriptor/gradle.properties").asFile
propFile.inputStream().use { load(it) }
}
val mcCatalog = versionCatalogs.named("mcLibs")
group = "de.siphalor.tweed5.minecraft.${project.name}"
val archivesBaseName = "${project.name}-mc$minecraftVersionDescriptor"
base {
archivesName.set(archivesBaseName)
}
val shortVersion = project.property("tweed5.version").toString()
val minecraftVersion = getMcCatalogVersion("minecraft")
version = "$shortVersion+mc$minecraftVersion"
sourceSets {
create("testmod") {
compileClasspath += sourceSets.main.get().compileClasspath
runtimeClasspath += sourceSets.main.get().runtimeClasspath
}
}
// For some reason dependencyResolutionManagement from the settings.gradle doesn't seem to be passed through correctly,
// so we're defining the repositories right here
repositories {
maven {
name = "Parchment"
url = uri("https://maven.parchmentmc.org")
mavenContent {
includeGroupAndSubgroups("org.parchmentmc")
}
}
maven {
name = "Siphalor"
url = uri("https://maven.siphalor.de")
mavenContent {
includeGroupAndSubgroups("de.siphalor")
}
}
}
dependencies {
minecraft(mcCatalog.findLibrary("minecraft").get())
mappings(loom.layered {
officialMojangMappings()
parchment("org.parchmentmc.data:parchment-$minecraftVersion:${getMcCatalogVersion("parchment")}@zip")
})
modImplementation(mcCommonLibs.fabric.loader)
}
fun getMcCatalogVersion(name: String): String {
return mcCatalog.findVersion(name).get().requiredVersion
}

View File

@@ -0,0 +1 @@
minecraft.version.descriptor = 1.21.10

View File

@@ -0,0 +1,8 @@
[versions]
coat = "1.0.0-beta.23"
minecraft = "1.21.10"
parchment = "2025.10.12"
[libraries]
coat = { group = "de.siphalor.coat", name = "coat-mc1.21.10", version.ref = "coat" }
minecraft = { group = "com.mojang", name = "minecraft", version.ref = "minecraft" }

View File

@@ -0,0 +1,11 @@
[versions]
fabric-loader = "0.17.2"
fabric-loom = "1.11-SNAPSHOT"
jcyo = "0.4.2"
[plugins]
jcyo = { id = "de.siphalor.jcyo", version.ref = "jcyo" }
fabric-loom = { id = "fabric-loom", version.ref = "fabric-loom" }
[libraries]
fabric-loader = { group = "net.fabricmc", name = "fabric-loader", version.ref = "fabric-loader" }

View File

@@ -2,25 +2,54 @@ rootProject.name = "tweed5-minecraft"
pluginManagement {
includeBuild("../conventions")
includeBuild("conventions")
repositories {
gradlePluginPortal()
maven {
name = "Siphalor"
url = uri("https://maven.siphalor.de")
mavenContent {
includeGroupAndSubgroups("de.siphalor")
}
}
maven {
name = "FabricMC"
url = uri("https://maven.fabricmc.net")
mavenContent {
includeGroupAndSubgroups("net.fabricmc")
includeGroup("fabric-loom")
}
}
}
}
dependencyResolutionManagement {
repositories {
mavenCentral()
}
versionCatalogs {
create("libs") {
from(files("../gradle/libs.versions.toml"))
}
create("mcCommonLibs") {
from(files("gradle/mcCommonLibs.versions.toml"))
}
create("mcLibs") {
val mcVersionDescriptor = providers.gradleProperty("minecraft.version.descriptor").get()
from(files("gradle/mc-$mcVersionDescriptor/mcLibs.versions.toml"))
}
}
}
includeBuild("../tweed5")
includeNormalModule("bundle")
includeNormalModule("coat-bridge")
fun includeNormalModule(name: String) {
includeAs("tweed5-$name", "$name")
includeAs("tweed5-$name", name)
}
fun includeAs(name: String, path: String) {