From d9c06a5504d8951315d4919e7a3629ccae36b48a Mon Sep 17 00:00:00 2001 From: Alexander Date: Sun, 10 Dec 2023 11:20:11 +0000 Subject: [PATCH] Cleanup the mod's Gradle boilerplate --- mod/build.gradle | 3 + mod/common/build.gradle | 41 +++++-------- ...p-sync.json => mapsync.common.mixins.json} | 0 mod/fabric/build.gradle | 57 +++++++------------ 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 | 50 ++++++---------- .../src/main/resources/META-INF/mods.toml | 17 +++--- .../main/resources/mapsync.forge.mixins.json | 14 +++++ mod/forge/src/main/resources/pack.mcmeta | 2 +- mod/gradle.properties | 7 ++- mod/settings.gradle | 2 +- 13 files changed, 115 insertions(+), 122 deletions(-) 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/build.gradle b/mod/build.gradle index c96564f6..7e9f46ec 100644 --- a/mod/build.gradle +++ b/mod/build.gradle @@ -44,6 +44,9 @@ allprojects { includeGroup "maven.modrinth" } } + maven { + url "https://www.jitpack.io" + } } tasks.withType(JavaCompile) { diff --git a/mod/common/build.gradle b/mod/common/build.gradle index bfb973f6..8d274b85 100644 --- a/mod/common/build.gradle +++ b/mod/common/build.gradle @@ -3,23 +3,22 @@ plugins { id("net.kyori.blossom") version "1.3.1" } -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}" - +architectury { + injectInjectables = false + common(rootProject.enabled_platforms.split(",")) +} +dependencies { + // Do NOT use other classes from fabric loader, we only use this fabric @Environment and mixin annotations! + 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" - // 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" -} + // VoxelMap 1.11.2 (https://modrinth.com/mod/voxelmap-updated/version/1.18.2-1.11.2) + modCompileOnlyApi("maven.modrinth:voxelmap-updated:SDVTG1wT") -architectury { - common(rootProject.enabled_platforms.split(",")) + // JourneyMap API 1.9 (https://www.jitpack.io/#TeamJM/journeymap-api) + compileOnlyApi("com.github.TeamJM:journeymap-api:1.18.2_1.9-SNAPSHOT") + // JourneyMap 5.9.7 (https://modrinth.com/mod/journeymap/version/1.18.2-5.9.7-fabric) + modCompileOnlyApi("maven.modrinth:journeymap:5JbcGXLn") } tasks { @@ -31,17 +30,3 @@ tasks { ) } } - -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. - } -} 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..e7d42f56 100644 --- a/mod/fabric/build.gradle +++ b/mod/fabric/build.gradle @@ -16,32 +16,29 @@ 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" - // 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" + // ModMenu 3.2.5 + modCompileOnly("maven.modrinth:modmenu:nVxObSbX") // https://modrinth.com/mod/modmenu/version/3.2.5 } processResources { - inputs.property "version", project.version - filesMatching("fabric.mod.json") { - expand "version": project.version + expand([ + "mod_version": rootProject.mod_version, + "mod_description": rootProject.mod_description, + "mod_home_url": rootProject.mod_home_url, + "mod_source_url": rootProject.mod_source_url, + "mod_issues_url": rootProject.mod_issues_url, + "copyright_licence": rootProject.copyright_licence, + + "minecraft_version": rootProject.minecraft_version, + "fabric_loader_version": rootProject.fabric_loader_version + ]) } } @@ -72,30 +69,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..32f6ce04 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": "MapSync", + "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..867bde1c 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 } - - - - // 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" + shadowCommon(project(path: ":common", configuration: "transformProductionForge")) { transitive false } } processResources { - inputs.property "version", project.version - filesMatching("META-INF/mods.toml") { - expand "version": project.version + expand([ + "mod_issues_url": rootProject.mod_issues_url, + "copyright_licence": rootProject.copyright_licence, + + "mod_version": rootProject.mod_version, + "mod_description": rootProject.mod_description, + "mod_home_url": rootProject.mod_home_url, + + "minecraft_version": rootProject.minecraft_version + ]) } } @@ -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..3874bdd5 100644 --- a/mod/forge/src/main/resources/META-INF/mods.toml +++ b/mod/forge/src/main/resources/META-INF/mods.toml @@ -1,16 +1,15 @@ modLoader = "javafml" loaderVersion = "[40,)" -issueTrackerURL = "https://github.com/CivPlatform/map-sync/issues" -license = "GPL-3.0-only" +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 = "MapSync" +description = "${mod_description}" +displayURL = "${mod_home_url}" +authors = "Gjum,Protonull" #logoFile = "" [[dependencies.mapsync]] @@ -23,6 +22,6 @@ 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..aee72f2c 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": "MapSync", "pack_format": 6 } } diff --git a/mod/gradle.properties b/mod/gradle.properties index edc7870e..3aea435e 100644 --- a/mod/gradle.properties +++ b/mod/gradle.properties @@ -1,8 +1,13 @@ 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_description=Share map data with your friends, live, privately. +copyright_licence=GPLv3 +mod_home_url=https://github.com/Protonull/MapSync +mod_source_url=https://github.com/Protonull/MapSync +mod_issues_url=https://github.com/Protonull/MapSync/issues minecraft_version=1.18.2 enabled_platforms=fabric,forge diff --git a/mod/settings.gradle b/mod/settings.gradle index 6cd13299..3bc2f5d4 100644 --- a/mod/settings.gradle +++ b/mod/settings.gradle @@ -11,4 +11,4 @@ include("common") include("fabric") include("forge") -rootProject.name = "map-sync" +rootProject.name = "MapSync"