From f0cd0e85a5ce9ea9598ee868cf4b9bdf0b555b0d Mon Sep 17 00:00:00 2001 From: Alexander Date: Tue, 16 Apr 2024 14:35:54 +0100 Subject: [PATCH 1/3] Update Gradle and modloader boilerplate --- mod/common/build.gradle | 36 ++++++--------- .../resources/assets/map-sync/lang/en_us.json | 4 -- .../resources/assets/mapsync/lang/en_us.json | 4 ++ ...p-sync.json => mapsync.common.mixins.json} | 0 mod/fabric/build.gradle | 44 ++++++------------- mod/fabric/gradle.properties | 1 + mod/fabric/src/main/resources/fabric.mod.json | 29 ++++++------ .../main/resources/mapsync.fabric.mixins.json | 14 ++++++ mod/forge/build.gradle | 44 +++++++------------ .../src/main/resources/META-INF/mods.toml | 21 +++++---- .../main/resources/mapsync.forge.mixins.json | 14 ++++++ mod/forge/src/main/resources/pack.mcmeta | 2 +- mod/gradle.properties | 15 +++++-- mod/settings.gradle | 8 ++-- 14 files changed, 117 insertions(+), 119 deletions(-) delete mode 100644 mod/common/src/main/resources/assets/map-sync/lang/en_us.json create mode 100644 mod/common/src/main/resources/assets/mapsync/lang/en_us.json rename mod/common/src/main/resources/{mixin.map-sync.json => mapsync.common.mixins.json} (100%) create mode 100644 mod/fabric/gradle.properties create mode 100644 mod/fabric/src/main/resources/mapsync.fabric.mixins.json create mode 100644 mod/forge/src/main/resources/mapsync.forge.mixins.json diff --git a/mod/common/build.gradle b/mod/common/build.gradle index f7859d4f..999ab4b2 100644 --- a/mod/common/build.gradle +++ b/mod/common/build.gradle @@ -3,45 +3,37 @@ plugins { id("net.kyori.blossom") version "1.3.1" } +architectury { + injectInjectables = false + common(rootProject.enabled_platforms.split(",")) +} + dependencies { // We depend on fabric loader here to use the fabric @Environment annotations and get the mixin dependencies // Do NOT use other classes from fabric loader modImplementation "net.fabricmc:fabric-loader:${rootProject.fabric_loader_version}" - // https://modrinth.com/mod/voxelmap-updated/version/1.18.2-1.11.2 (1.11.2 fabric) - modCompileOnly "maven.modrinth:voxelmap-updated:SDVTG1wT" + modCompileOnly("maven.modrinth:voxelmap-updated:SDVTG1wT") // https://modrinth.com/mod/journeymap/version/1.18.2-5.9.7-fabric (5.9.7 fabric) - modCompileOnly "maven.modrinth:journeymap:5JbcGXLn" + modCompileOnly("maven.modrinth:journeymap:5JbcGXLn") // https://modrinth.com/mod/xaeros-minimap/version/23.6.2_Fabric_1.18.2 (23.6.2 fabric) - modCompileOnly "maven.modrinth:xaeros-minimap:Jwydpps9" -} - -architectury { - common(rootProject.enabled_platforms.split(",")) + modCompileOnly("maven.modrinth:xaeros-minimap:Jwydpps9") } tasks { blossom { replaceToken ( - "%VERSION%", - project.version, - "src/main/java/gjum/minecraft/mapsync/common/MapSyncMod.java" + "%VERSION%", + project.version, + "src/main/java/gjum/minecraft/mapsync/common/MapSyncMod.java" ) } } -publishing { - publications { - mavenCommon(MavenPublication) { - artifactId = rootProject.archives_base_name - from components.java - } - } - - // See https://docs.gradle.org/current/userguide/publishing_maven.html for information on how to set up publishing. - repositories { - // Add repositories to publish to here. +processResources { + filesMatching("assets/mapsync/lang/en_us.json") { + expand(rootProject.properties) } } diff --git a/mod/common/src/main/resources/assets/map-sync/lang/en_us.json b/mod/common/src/main/resources/assets/map-sync/lang/en_us.json deleted file mode 100644 index 1f439487..00000000 --- a/mod/common/src/main/resources/assets/map-sync/lang/en_us.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "key.map-sync.openGui": "Open GUI", - "category.map-sync": "Map Sync" -} diff --git a/mod/common/src/main/resources/assets/mapsync/lang/en_us.json b/mod/common/src/main/resources/assets/mapsync/lang/en_us.json new file mode 100644 index 00000000..1dfbf945 --- /dev/null +++ b/mod/common/src/main/resources/assets/mapsync/lang/en_us.json @@ -0,0 +1,4 @@ +{ + "key.map-sync.openGui": "Open GUI", + "category.map-sync": "${mod_display_name}" +} diff --git a/mod/common/src/main/resources/mixin.map-sync.json b/mod/common/src/main/resources/mapsync.common.mixins.json similarity index 100% rename from mod/common/src/main/resources/mixin.map-sync.json rename to mod/common/src/main/resources/mapsync.common.mixins.json diff --git a/mod/fabric/build.gradle b/mod/fabric/build.gradle index 276503ee..77191b47 100644 --- a/mod/fabric/build.gradle +++ b/mod/fabric/build.gradle @@ -16,32 +16,28 @@ configurations { } dependencies { - modImplementation "net.fabricmc:fabric-loader:${rootProject.fabric_loader_version}" - modApi "net.fabricmc.fabric-api:fabric-api:${rootProject.fabric_api_version}" + modImplementation("net.fabricmc:fabric-loader:${rootProject.fabric_loader_version}") + modApi("net.fabricmc.fabric-api:fabric-api:${rootProject.fabric_api_version}") common(project(path: ":common", configuration: "namedElements")) { transitive false } shadowCommon(project(path: ":common", configuration: "transformProductionFabric")) { transitive false } - // https://modrinth.com/mod/voxelmap-updated/version/1.18.2-1.11.2 (1.11.2 fabric) - modCompileOnly "maven.modrinth:voxelmap-updated:SDVTG1wT" + modCompileOnly("maven.modrinth:voxelmap-updated:SDVTG1wT") // https://modrinth.com/mod/journeymap/version/1.18.2-5.9.7-fabric (5.9.7 fabric) - modCompileOnly "maven.modrinth:journeymap:5JbcGXLn" + modCompileOnly("maven.modrinth:journeymap:5JbcGXLn") // https://modrinth.com/mod/xaeros-minimap/version/23.6.2_Fabric_1.18.2 (23.6.2 fabric) - modCompileOnly "maven.modrinth:xaeros-minimap:Jwydpps9" - + modCompileOnly("maven.modrinth:xaeros-minimap:Jwydpps9") // https://modrinth.com/mod/modmenu/version/3.2.5 (3.2.5 fabric) - modCompileOnly "maven.modrinth:modmenu:nVxObSbX" + modCompileOnly("maven.modrinth:modmenu:nVxObSbX") } processResources { - inputs.property "version", project.version - filesMatching("fabric.mod.json") { - expand "version": project.version + expand(rootProject.properties) } } @@ -51,7 +47,7 @@ shadowJar { } remapJar { - input.set shadowJar.archiveFile + inputFile.set(shadowJar.archiveFile) dependsOn shadowJar classifier "fabric" } @@ -72,30 +68,16 @@ components.java { } } -publishing { - publications { - mavenFabric(MavenPublication) { - artifactId = rootProject.archives_base_name + "-" + project.name - from components.java - } - } - - // See https://docs.gradle.org/current/userguide/publishing_maven.html for information on how to set up publishing. - repositories { - // Add repositories to publish to here. - } -} - -tasks.register('cleanJar', Delete) { - delete fileTree('../dist') { +tasks.register("cleanJar", Delete) { + delete fileTree("../dist") { include "*-fabric.jar" } } -tasks.register('copyJar', Copy) { +tasks.register("copyJar", Copy) { + dependsOn cleanJar from remapJar - into '../dist' + into "../dist" } build.dependsOn copyJar -copyJar.dependsOn cleanJar diff --git a/mod/fabric/gradle.properties b/mod/fabric/gradle.properties new file mode 100644 index 00000000..e846a8f5 --- /dev/null +++ b/mod/fabric/gradle.properties @@ -0,0 +1 @@ +loom.platform=fabric diff --git a/mod/fabric/src/main/resources/fabric.mod.json b/mod/fabric/src/main/resources/fabric.mod.json index 1753d049..9eac7e2f 100644 --- a/mod/fabric/src/main/resources/fabric.mod.json +++ b/mod/fabric/src/main/resources/fabric.mod.json @@ -1,18 +1,20 @@ { "schemaVersion": 1, - "id": "map-sync", - "version": "${version}", - "name": "Map Sync", - "description": "Sync map data with others instantly.", + "id": "mapsync", + "version": "${mod_version}", + "name": "${mod_display_name}", + "description": "${mod_description}", "authors": [ - "Gjum" + "Gjum", + "Protonull" ], "contact": { - "homepage": "https://github.com/Gjum/map-sync", - "sources": "https://github.com/Gjum/map-sync" + "homepage": "${mod_home_url}", + "sources": "${mod_source_url}", + "issues": "${mod_issues_url}" }, - "license": "GPL-3.0-only", - "icon": "assets/map-sync/icon.png", + "license": "${copyright_licence}", + "icon": "assets/mapsync/icon.png", "environment": "client", "entrypoints": { "client": [ @@ -23,11 +25,12 @@ ] }, "depends": { - "fabricloader": ">=0.7.4", - "fabric": "*", - "minecraft": "1.18.x" + "minecraft": "${minecraft_version}", + "fabricloader": ">=${fabric_loader_version}", + "fabric": "*" }, "mixins": [ - "mixin.map-sync.json" + "mapsync.common.mixins.json", + "mapsync.fabric.mixins.json" ] } diff --git a/mod/fabric/src/main/resources/mapsync.fabric.mixins.json b/mod/fabric/src/main/resources/mapsync.fabric.mixins.json new file mode 100644 index 00000000..78cd499b --- /dev/null +++ b/mod/fabric/src/main/resources/mapsync.fabric.mixins.json @@ -0,0 +1,14 @@ +{ + "required": true, + "minVersion": "0.8", + "package": "gjum.minecraft.mapsync.fabric.mixins", + "compatibilityLevel": "JAVA_17", + "mixins": [], + "client": [ + + ], + "server": [], + "injectors": { + "defaultRequire": 1 + } +} diff --git a/mod/forge/build.gradle b/mod/forge/build.gradle index e1882c28..4239a8a3 100644 --- a/mod/forge/build.gradle +++ b/mod/forge/build.gradle @@ -9,7 +9,7 @@ architectury { loom { forge { - mixinConfig "mixin.map-sync.json" + mixinConfig "mapsync.common.mixins.json", "mapsync.forge.mixins.json" } } @@ -22,24 +22,24 @@ configurations { } dependencies { - forge "net.minecraftforge:forge:${rootProject.forge_version}" + forge("net.minecraftforge:forge:${rootProject.forge_version}") common(project(path: ":common", configuration: "namedElements")) { transitive false } - shadowCommon(project(path: ":common", configuration: "transformProductionForge")) { transitive = false } - + shadowCommon(project(path: ":common", configuration: "transformProductionForge")) { transitive false } // https://modrinth.com/mod/journeymap/version/1.18.2-5.9.7-forge (5.9.7 forge) - modCompileOnly "maven.modrinth:journeymap:2G6aMzKY" + modCompileOnly("maven.modrinth:journeymap:2G6aMzKY") // https://modrinth.com/mod/xaeros-minimap/version/23.6.2_Forge_1.18.2 (23.6.2 forge) - modCompileOnly "maven.modrinth:xaeros-minimap:yFuICfIq" + modCompileOnly("maven.modrinth:xaeros-minimap:yFuICfIq") } processResources { - inputs.property "version", project.version - filesMatching("META-INF/mods.toml") { - expand "version": project.version + expand(rootProject.properties) + } + filesMatching("pack.mcmeta") { + expand(rootProject.properties) } } @@ -51,7 +51,7 @@ shadowJar { } remapJar { - input.set shadowJar.archiveFile + inputFile.set(shadowJar.archiveFile) dependsOn shadowJar classifier "forge" } @@ -72,30 +72,16 @@ components.java { } } -publishing { - publications { - mavenForge(MavenPublication) { - artifactId = rootProject.archives_base_name + "-" + project.name - from components.java - } - } - - // See https://docs.gradle.org/current/userguide/publishing_maven.html for information on how to set up publishing. - repositories { - // Add repositories to publish to here. - } -} - -tasks.register('cleanJar', Delete) { - delete fileTree('../dist') { +tasks.register("cleanJar", Delete) { + delete fileTree("../dist") { include "*-forge.jar" } } -tasks.register('copyJar', Copy) { +tasks.register("copyJar", Copy) { + dependsOn cleanJar from remapJar - into '../dist' + into "../dist" } build.dependsOn copyJar -copyJar.dependsOn cleanJar diff --git a/mod/forge/src/main/resources/META-INF/mods.toml b/mod/forge/src/main/resources/META-INF/mods.toml index ffc23c7e..f49b6c5c 100644 --- a/mod/forge/src/main/resources/META-INF/mods.toml +++ b/mod/forge/src/main/resources/META-INF/mods.toml @@ -1,28 +1,27 @@ modLoader = "javafml" -loaderVersion = "[40,)" -issueTrackerURL = "https://github.com/CivPlatform/map-sync/issues" -license = "GPL-3.0-only" +loaderVersion = "[${forge_major_version},)" +issueTrackerURL = "${mod_issues_url}" +license = "${copyright_licence}" [[mods]] modId = "mapsync" -version = "${version}" -displayName = "Map Sync" -authors = "Gjum" -description = ''' -Sync map data with others instantly. -''' +version = "${mod_version}" +displayName = "${mod_display_name}" +description = "${mod_description}" +displayURL = "${mod_home_url}" +authors = "Gjum,Protonull" #logoFile = "" [[dependencies.mapsync]] modId = "forge" mandatory = true -versionRange = "[40,)" +versionRange = "[${forge_major_version},)" ordering = "NONE" side = "CLIENT" [[dependencies.mapsync]] modId = "minecraft" mandatory = true -versionRange = "[1.18.2,)" +versionRange = "[${minecraft_version},)" ordering = "NONE" side = "CLIENT" diff --git a/mod/forge/src/main/resources/mapsync.forge.mixins.json b/mod/forge/src/main/resources/mapsync.forge.mixins.json new file mode 100644 index 00000000..4792d957 --- /dev/null +++ b/mod/forge/src/main/resources/mapsync.forge.mixins.json @@ -0,0 +1,14 @@ +{ + "required": true, + "minVersion": "0.8", + "package": "gjum.minecraft.mapsync.forge.mixins", + "compatibilityLevel": "JAVA_17", + "mixins": [], + "client": [ + + ], + "server": [], + "injectors": { + "defaultRequire": 1 + } +} diff --git a/mod/forge/src/main/resources/pack.mcmeta b/mod/forge/src/main/resources/pack.mcmeta index e7a57a5c..0621a435 100644 --- a/mod/forge/src/main/resources/pack.mcmeta +++ b/mod/forge/src/main/resources/pack.mcmeta @@ -1,6 +1,6 @@ { "pack": { - "description": "Map Sync", + "description": "${mod_display_name}", "pack_format": 6 } } diff --git a/mod/gradle.properties b/mod/gradle.properties index edc7870e..49a90517 100644 --- a/mod/gradle.properties +++ b/mod/gradle.properties @@ -1,14 +1,21 @@ org.gradle.jvmargs=-Xmx2048M -archives_base_name=map-sync +archives_base_name=MapSync maven_group=gjum.minecraft.mapsync mod_version=2.0.1-1.18.2 +mod_display_name=MapSync +mod_description=Share map data with your friends, live, and privately. +copyright_licence=GPLv3 +mod_home_url=https://github.com/CivPlatform/map-sync +mod_source_url=https://github.com/CivPlatform/map-sync +mod_issues_url=https://github.com/CivPlatform/map-sync/issues minecraft_version=1.18.2 enabled_platforms=fabric,forge # https://fabricmc.net/versions.html -fabric_loader_version=0.14.9 -fabric_api_version=0.58.0+1.18.2 +fabric_loader_version=0.15.10 +fabric_api_version=0.77.0+1.18.2 -forge_version=1.18.2-40.1.73 +forge_version=1.18.2-40.2.0 +forge_major_version=40 diff --git a/mod/settings.gradle b/mod/settings.gradle index 6cd13299..9ab08e8b 100644 --- a/mod/settings.gradle +++ b/mod/settings.gradle @@ -7,8 +7,8 @@ pluginManagement { } } -include("common") -include("fabric") -include("forge") +include(":common") +include(":fabric") +include(":forge") -rootProject.name = "map-sync" +rootProject.name = "MapSync" From f96212c47d3a1cc3474b8eb4e472e1aa85c11e98 Mon Sep 17 00:00:00 2001 From: Alexander Date: Thu, 18 Apr 2024 23:39:21 +0100 Subject: [PATCH 2/3] Remove unnecessary dependencies from fabric and forge --- mod/fabric/build.gradle | 9 --------- mod/forge/build.gradle | 6 ------ 2 files changed, 15 deletions(-) diff --git a/mod/fabric/build.gradle b/mod/fabric/build.gradle index 77191b47..d1d5b794 100644 --- a/mod/fabric/build.gradle +++ b/mod/fabric/build.gradle @@ -22,15 +22,6 @@ dependencies { common(project(path: ":common", configuration: "namedElements")) { transitive false } shadowCommon(project(path: ":common", configuration: "transformProductionFabric")) { transitive false } - - // https://modrinth.com/mod/voxelmap-updated/version/1.18.2-1.11.2 (1.11.2 fabric) - modCompileOnly("maven.modrinth:voxelmap-updated:SDVTG1wT") - // https://modrinth.com/mod/journeymap/version/1.18.2-5.9.7-fabric (5.9.7 fabric) - modCompileOnly("maven.modrinth:journeymap:5JbcGXLn") - // https://modrinth.com/mod/xaeros-minimap/version/23.6.2_Fabric_1.18.2 (23.6.2 fabric) - modCompileOnly("maven.modrinth:xaeros-minimap:Jwydpps9") - - // https://modrinth.com/mod/modmenu/version/3.2.5 (3.2.5 fabric) modCompileOnly("maven.modrinth:modmenu:nVxObSbX") } diff --git a/mod/forge/build.gradle b/mod/forge/build.gradle index 4239a8a3..8eb12c2c 100644 --- a/mod/forge/build.gradle +++ b/mod/forge/build.gradle @@ -26,12 +26,6 @@ dependencies { common(project(path: ":common", configuration: "namedElements")) { transitive false } shadowCommon(project(path: ":common", configuration: "transformProductionForge")) { transitive false } - - - // https://modrinth.com/mod/journeymap/version/1.18.2-5.9.7-forge (5.9.7 forge) - modCompileOnly("maven.modrinth:journeymap:2G6aMzKY") - // https://modrinth.com/mod/xaeros-minimap/version/23.6.2_Forge_1.18.2 (23.6.2 forge) - modCompileOnly("maven.modrinth:xaeros-minimap:yFuICfIq") } processResources { From 90484b07f53e9e708d340fc729b5b8e1ea3b3b9c Mon Sep 17 00:00:00 2001 From: Alexander Date: Fri, 19 Apr 2024 01:27:37 +0100 Subject: [PATCH 3/3] Add authors filtering --- mod/fabric/build.gradle | 8 ++++++++ mod/fabric/src/main/resources/fabric.mod.json | 5 +---- mod/forge/src/main/resources/META-INF/mods.toml | 2 +- mod/gradle.properties | 1 + 4 files changed, 11 insertions(+), 5 deletions(-) diff --git a/mod/fabric/build.gradle b/mod/fabric/build.gradle index d1d5b794..f11d87c1 100644 --- a/mod/fabric/build.gradle +++ b/mod/fabric/build.gradle @@ -1,3 +1,5 @@ +import groovy.json.JsonBuilder + plugins { id "com.github.johnrengelman.shadow" version "7.1.2" } @@ -29,6 +31,12 @@ dependencies { processResources { filesMatching("fabric.mod.json") { expand(rootProject.properties) + filter { + (it as String).replace( + "\"%FABRIC_AUTHORS_ARRAY%\"", + new JsonBuilder((rootProject.properties["mod_authors"] as String).tokenize(",")).toString() + ) + } } } diff --git a/mod/fabric/src/main/resources/fabric.mod.json b/mod/fabric/src/main/resources/fabric.mod.json index 9eac7e2f..e862cf8b 100644 --- a/mod/fabric/src/main/resources/fabric.mod.json +++ b/mod/fabric/src/main/resources/fabric.mod.json @@ -4,10 +4,7 @@ "version": "${mod_version}", "name": "${mod_display_name}", "description": "${mod_description}", - "authors": [ - "Gjum", - "Protonull" - ], + "authors": "%FABRIC_AUTHORS_ARRAY%", "contact": { "homepage": "${mod_home_url}", "sources": "${mod_source_url}", diff --git a/mod/forge/src/main/resources/META-INF/mods.toml b/mod/forge/src/main/resources/META-INF/mods.toml index f49b6c5c..9940224e 100644 --- a/mod/forge/src/main/resources/META-INF/mods.toml +++ b/mod/forge/src/main/resources/META-INF/mods.toml @@ -9,7 +9,7 @@ version = "${mod_version}" displayName = "${mod_display_name}" description = "${mod_description}" displayURL = "${mod_home_url}" -authors = "Gjum,Protonull" +authors = "${mod_authors}" #logoFile = "" [[dependencies.mapsync]] diff --git a/mod/gradle.properties b/mod/gradle.properties index 49a90517..8d187eab 100644 --- a/mod/gradle.properties +++ b/mod/gradle.properties @@ -5,6 +5,7 @@ maven_group=gjum.minecraft.mapsync mod_version=2.0.1-1.18.2 mod_display_name=MapSync mod_description=Share map data with your friends, live, and privately. +mod_authors=Gjum,Protonull,okx,Huskydog9988,specificlanguage,SirAlador,klaribot copyright_licence=GPLv3 mod_home_url=https://github.com/CivPlatform/map-sync mod_source_url=https://github.com/CivPlatform/map-sync