From dca14825265e6992ab91dc8a037e115a7261cc50 Mon Sep 17 00:00:00 2001 From: xtex Date: Tue, 1 Aug 2023 16:56:38 +0800 Subject: [PATCH] feat: add quilt support It is not working at all --- fabric-like/build.gradle.kts | 17 ---- fabric/build.gradle.kts | 6 -- .../kotlin/quaedam/fabric/QuaedamQuilt.kt | 4 +- fabric/src/main/resources/fabric.mod.json | 2 +- .../src/main/resources/quaedam.mixins.json | 0 gradle.properties | 12 ++- quilt/build.gradle.kts | 86 +++++++++++++++++++ quilt/gradle.properties | 1 + .../main/kotlin/quaedam.quilt/QuaedamQuilt.kt | 12 +++ quilt/src/main/resources/quaedam.mixins.json | 13 +++ quilt/src/main/resources/quilt.mod.json | 59 +++++++++++++ settings.gradle.kts | 2 +- 12 files changed, 186 insertions(+), 28 deletions(-) delete mode 100644 fabric-like/build.gradle.kts rename fabric-like/src/main/kotlin/quaedam.fabriclike/QuaedamFabricLike.kt => fabric/src/main/kotlin/quaedam/fabric/QuaedamQuilt.kt (65%) rename {fabric-like => fabric}/src/main/resources/quaedam.mixins.json (100%) create mode 100644 quilt/build.gradle.kts create mode 100644 quilt/gradle.properties create mode 100644 quilt/src/main/kotlin/quaedam.quilt/QuaedamQuilt.kt create mode 100644 quilt/src/main/resources/quaedam.mixins.json create mode 100644 quilt/src/main/resources/quilt.mod.json diff --git a/fabric-like/build.gradle.kts b/fabric-like/build.gradle.kts deleted file mode 100644 index 4a406fa..0000000 --- a/fabric-like/build.gradle.kts +++ /dev/null @@ -1,17 +0,0 @@ -architectury { - common("fabric", "quilt") -} - -loom { - accessWidenerPath.set(project(":common").loom.accessWidenerPath) -} - -dependencies { - modImplementation("net.fabricmc:fabric-loader:${rootProject.property("fabric_loader_version")}") - modApi("net.fabricmc.fabric-api:fabric-api:${rootProject.property("fabric_version")}") - modApi("dev.architectury:architectury-fabric:${rootProject.property("architectury_version")}") - - compileOnly(project(":common", "namedElements")) { - isTransitive = false - } -} diff --git a/fabric/build.gradle.kts b/fabric/build.gradle.kts index e387460..7974946 100644 --- a/fabric/build.gradle.kts +++ b/fabric/build.gradle.kts @@ -33,12 +33,6 @@ dependencies { shadowCommon(project(":common", "transformProductionFabric")){ isTransitive = false } - common(project(":fabric-like", "namedElements")) { - isTransitive = false - } - shadowCommon(project(":fabric-like", "transformProductionFabric")){ - isTransitive = false - } } tasks.processResources { diff --git a/fabric-like/src/main/kotlin/quaedam.fabriclike/QuaedamFabricLike.kt b/fabric/src/main/kotlin/quaedam/fabric/QuaedamQuilt.kt similarity index 65% rename from fabric-like/src/main/kotlin/quaedam.fabriclike/QuaedamFabricLike.kt rename to fabric/src/main/kotlin/quaedam/fabric/QuaedamQuilt.kt index 98c9bab..c48e61e 100644 --- a/fabric-like/src/main/kotlin/quaedam.fabriclike/QuaedamFabricLike.kt +++ b/fabric/src/main/kotlin/quaedam/fabric/QuaedamQuilt.kt @@ -1,9 +1,9 @@ -package quaedam.fabriclike +package quaedam.fabric import net.fabricmc.api.ModInitializer import quaedam.Quaedam -object QuaedamFabricLike: ModInitializer { +object QuaedamFabric: ModInitializer { override fun onInitialize() { Quaedam.init() diff --git a/fabric/src/main/resources/fabric.mod.json b/fabric/src/main/resources/fabric.mod.json index 09f8d4e..157ddf5 100644 --- a/fabric/src/main/resources/fabric.mod.json +++ b/fabric/src/main/resources/fabric.mod.json @@ -18,7 +18,7 @@ "main": [ { "adapter": "kotlin", - "value": "quaedam.fabriclike.QuaedamFabricLike" + "value": "quaedam.fabric.QuaedamFabric" } ] }, diff --git a/fabric-like/src/main/resources/quaedam.mixins.json b/fabric/src/main/resources/quaedam.mixins.json similarity index 100% rename from fabric-like/src/main/resources/quaedam.mixins.json rename to fabric/src/main/resources/quaedam.mixins.json diff --git a/gradle.properties b/gradle.properties index 2cc34e2..afead01 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,15 +3,25 @@ org.gradle.caching=true org.gradle.jvmargs=-Xmx2048M minecraft_version=1.20.1 -parchment_version=2023.07.16 +parchment_version=2023.07.30 # https://modrinth.com/mod/architectury-api architectury_version=9.1.12 + # https://files.minecraftforge.net/net/minecraftforge/forge/ forge_version=1.20.1-47.1.43 # https://modrinth.com/mod/kotlin-for-forge kotlin_for_forge_version=4.4.0 + # https://fabricmc.net/develop/ fabric_loader_version=0.14.21 fabric_version=0.86.1+1.20.1 # https://modrinth.com/mod/fabric-language-kotlin fabric_kotlin_version=1.10.8+kotlin.1.9.0 + +# https://github.com/QuiltMC/quilt-loader/tags +quilt_loader_version=0.20.0-beta.5 +# https://modrinth.com/mod/qsl +quilt_fabric_version=7.0.3+0.83.1-1.20.1 +quilt_standard_library_version=6.0.4+1.20.1 +# https://modrinth.com/mod/qkl +quilt_kotlin_libraries_version=2.1.1+kt.1.9.0+flk.1.9.6 diff --git a/quilt/build.gradle.kts b/quilt/build.gradle.kts new file mode 100644 index 0000000..992410f --- /dev/null +++ b/quilt/build.gradle.kts @@ -0,0 +1,86 @@ +plugins { + id("com.github.johnrengelman.shadow") +} + +architectury { + platformSetupLoomIde() + loader("quilt") +} + +loom { + accessWidenerPath.set(project(":common").loom.accessWidenerPath) +} + +val common: Configuration by configurations.creating +val shadowCommon: Configuration by configurations.creating +val developmentQuilt: Configuration by configurations.getting + +configurations { + compileOnly.configure { extendsFrom(common) } + runtimeOnly.configure { extendsFrom(common) } + developmentQuilt.extendsFrom(common) +} + +dependencies { + modImplementation("org.quiltmc:quilt-loader:${rootProject.property("quilt_loader_version")}") + modApi("org.quiltmc.quilted-fabric-api:quilted-fabric-api:${rootProject.property("quilt_fabric_version")}") + modApi("dev.architectury:architectury-fabric:${rootProject.property("architectury_version")}") { + exclude("net.fabricmc") + exclude("net.fabricmc.fabric-api") + } + modApi("org.quiltmc:qsl:${rootProject.property("quilt_standard_library_version")}") + modApi("org.quiltmc.quilt-kotlin-libraries:quilt-kotlin-libraries:${rootProject.property("quilt_kotlin_libraries_version")}") + + common(project(":common", "namedElements")) { + isTransitive = false + } + shadowCommon(project(":common", "transformProductionQuilt")) { + isTransitive = false + } +} + +tasks.processResources { + inputs.property("version", project.version) + + filesMatching("quilt.mod.json") { + expand( + mapOf( + "version" to project.version, + + "minecraft_version" to rootProject.property("minecraft_version"), + "architectury_version" to rootProject.property("architectury_version"), + "quilt_kotlin_libraries_version" to rootProject.property("quilt_kotlin_libraries_version"), + ) + ) + } +} + +tasks.shadowJar { + exclude("architectury.common.json") + configurations = listOf(shadowCommon) + archiveClassifier.set("dev-shadow") +} + +tasks.remapJar { + injectAccessWidener.set(true) + inputFile.set(tasks.shadowJar.get().archiveFile) + dependsOn(tasks.shadowJar) + archiveClassifier.set(null as String?) +} + +tasks.jar { + archiveClassifier.set("dev") +} + +tasks.sourcesJar { + val commonSources = project(":common").tasks.getByName("sourcesJar") + dependsOn(commonSources) + from(commonSources.archiveFile.map { zipTree(it) }) +} + +components.getByName("java") { + this as AdhocComponentWithVariants + this.withVariantsFromConfiguration(project.configurations["shadowRuntimeElements"]) { + skip() + } +} \ No newline at end of file diff --git a/quilt/gradle.properties b/quilt/gradle.properties new file mode 100644 index 0000000..96758ce --- /dev/null +++ b/quilt/gradle.properties @@ -0,0 +1 @@ +loom.platform=quilt \ No newline at end of file diff --git a/quilt/src/main/kotlin/quaedam.quilt/QuaedamQuilt.kt b/quilt/src/main/kotlin/quaedam.quilt/QuaedamQuilt.kt new file mode 100644 index 0000000..73fc6a1 --- /dev/null +++ b/quilt/src/main/kotlin/quaedam.quilt/QuaedamQuilt.kt @@ -0,0 +1,12 @@ +package quaedam.quilt + +import net.fabricmc.api.ModInitializer +import quaedam.Quaedam + +object QuaedamQuilt: ModInitializer { + + override fun onInitialize() { + Quaedam.init() + } + +} \ No newline at end of file diff --git a/quilt/src/main/resources/quaedam.mixins.json b/quilt/src/main/resources/quaedam.mixins.json new file mode 100644 index 0000000..cf1aeb5 --- /dev/null +++ b/quilt/src/main/resources/quaedam.mixins.json @@ -0,0 +1,13 @@ +{ + "required": true, + "package": "quaedam.fabric.mixin", + "compatibilityLevel": "JAVA_17", + "minVersion": "0.8", + "client": [ + ], + "mixins": [ + ], + "injectors": { + "defaultRequire": 1 + } +} \ No newline at end of file diff --git a/quilt/src/main/resources/quilt.mod.json b/quilt/src/main/resources/quilt.mod.json new file mode 100644 index 0000000..c5ea218 --- /dev/null +++ b/quilt/src/main/resources/quilt.mod.json @@ -0,0 +1,59 @@ +{ + "_comment": "https://github.com/QuiltMC/rfcs/blob/main/specification/0002-quilt.mod.json.md", + "schema_version": 1, + "mixin": [ + "quaedam-common.mixins.json" + ], + "quilt_loader": { + "metadata": { + "name": "Quaedam", + "description": "Hot hot hot!", + "license": "Apache-2.0", + "authors": [ + "xtex" + ], + "contact": { + "homepage": "https://codeberg.org/xtex/quaedam", + "sources": "https://codeberg.org/xtex/quaedam" + }, + "icon": "assets/quaedam/icon.png" + }, + "group": "quaedam", + "id": "quaedam", + "version": "${version}", + "intermediate_mappings": "net.fabricmc:intermediary", + "entrypoints": { + "init": [ + { + "adapter": "kotlin", + "value": "quaedam.quilt.QuaedamQuilt" + } + ] + }, + "depends": [ + { + "id": "quilt_loader", + "version": "*" + }, + { + "id": "quilt_base", + "version": "*" + }, + { + "id": "minecraft", + "version": ">=${minecraft_version}" + }, + { + "id": "architectury", + "version": ">=${architectury_version}" + }, + { + "id": "qkl", + "version": ">=${quilt_kotlin_libraries_version}" + } + ] + }, + "minecraft": { + "environment": "*" + } +} \ No newline at end of file diff --git a/settings.gradle.kts b/settings.gradle.kts index 48b5288..787d4b8 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -10,6 +10,6 @@ pluginManagement { include("common") include("forge") -include("fabric-like", "fabric") +include("fabric", "quilt") rootProject.name = "quaedam"