From 1986b9a2c90f5e304dbc3455ef565525f9bd9b73 Mon Sep 17 00:00:00 2001 From: 50ap5ud5 <50ap5ud5125@gmail.com> Date: Mon, 30 Dec 2024 23:27:59 +1100 Subject: [PATCH] Cleanup build script, configure publishing plugin --- build.gradle | 119 ++++++++++++++++-- .../src/main/groovy/multiloader-common.gradle | 1 + fabric/build.gradle | 86 +------------ forge/build.gradle | 56 ++------- .../boatiview/forge/config/BConfig.java | 4 +- gradle.properties | 10 +- neoforge/build.gradle | 45 +------ .../boatiview/neoforge/BoatItemViewImpl.java | 2 - 8 files changed, 133 insertions(+), 190 deletions(-) diff --git a/build.gradle b/build.gradle index 365ec28..61df259 100644 --- a/build.gradle +++ b/build.gradle @@ -2,10 +2,10 @@ plugins { // see https://fabricmc.net/develop/ for new versions id 'fabric-loom' version '1.7-SNAPSHOT' apply false // see https://projects.neoforged.net/neoforged/moddevgradle for new versions - id 'net.neoforged.moddev' version '2.0.52-beta' apply false - id "net.darkhax.curseforgegradle" version "1.1.25" apply(false) - id "com.modrinth.minotaur" version "2.+" apply(false) -// id "me.shedaniel.unified-publishing" version "0.1.+" + id 'net.neoforged.moddev' version '2.0.72' apply false + id "me.modmuss50.mod-publish-plugin" version "0.8.3" + id 'net.minecraftforge.gradle' version '[6.0.24,6.2)' apply false + id 'org.spongepowered.mixin' version '0.7-SNAPSHOT' apply false } allprojects { @@ -15,8 +15,9 @@ allprojects { group = rootProject.maven_group repositories { + mavenCentral() maven { - url "https://cursemaven.com" + url = "https://cursemaven.com" } maven { @@ -34,7 +35,7 @@ allprojects { url = "https://maven.terraformersmc.com/" } - maven { url 'https://jitpack.io' } + maven { url = 'https://jitpack.io' } flatDir { dirs '../modlibs' @@ -49,8 +50,104 @@ allprojects { } -//task publishMeEverywhere(){ -// dependsOn ':neoforge:publishUnified' -// dependsOn ':fabric:publishUnified' -// dependsOn ':forge:publishUnified' -//} \ No newline at end of file +publishMods { + File changeLog = rootProject.file("changelog.md") + String changelogText = changeLog.exists() ? changeLog.text : "" + changelog = changelogText + + type = STABLE + + dryRun = true //Always enable for debug + + // CurseForge options used by both Fabric and Forge + def cfOptions = curseforgeOptions { + accessToken = providers.gradleProperty("CURSEFORGE_TOKEN") + minecraftVersions.add("1.21.4") + javaVersions.add(JavaVersion.VERSION_21) + clientRequired = true + dryRun = true + } + + // Modrinth options used by both Fabric and Forge + def mrOptions = modrinthOptions { + accessToken = providers.gradleProperty("MODRINTH_TOKEN") + projectId = "${modrinth_id}" + minecraftVersionRange { + start = "1.21.4" + end = "1.21.4" // Set to "latest" to use the latest minecraft version + } + dryRun = true + } + + // Fabric specific options for CurseForge + curseforge("curseforgeFabric") { + from cfOptions + file project(":fabric") + projectId = "${curseforge_id_fabric}" + modLoaders.add("fabric") + requires { + slug = "fabric-api" + } + embeds("cloth-config") + optional("modmenu") + version = "${minecraft_version}-${mod_version}-fabric" + displayName = "${jar_name}-Fabric-${minecraft_version}-${mod_version}" + } + + // Forge specific options for CurseForge + curseforge("curseforgeForge") { + from cfOptions + file project(":forge") + modLoaders.add("forge") + projectId = "${curseforge_id_forge}" + version = "${minecraft_version}-${mod_version}-forge" + displayName = "${jar_name}-Forge-${minecraft_version}-${mod_version}" + } + + // Neoforge specific options for Curseforge + curseforge("curseforgeNeoforge") { + from cfOptions + file project(":neoforge") + modLoaders.add("neoforge") + projectId = "${curseforge_id_forge}" + version = "${minecraft_version}-${mod_version}-neoforge" + displayName = "${jar_name}-Neoforge-${minecraft_version}-${mod_version}" + } + + // Fabric specific options for Modrinth + modrinth("modrinthFabric") { + from mrOptions + file project(":fabric") + modLoaders.add("fabric") + requires { + slug = "fabric-api" + } + embeds { + slug = "cloth-config" + } + optional { + slug = "modmenu" + } + version = "${minecraft_version}-${mod_version}-fabric" + displayName = "${jar_name}-Fabric-${minecraft_version}-${mod_version}" + } + + // Forge specific options for Modrinth + modrinth("modrinthForge") { + from mrOptions + file project(":forge") + modLoaders.add("forge") + version = "${minecraft_version}-${mod_version}-forge" + displayName = "${jar_name}-Forge-${minecraft_version}-${mod_version}" + } + + // Neoforge specific options for Modrinth + modrinth("modrinthNeoforge") { + from mrOptions + file project(":neoforge") + modLoaders.add("neoforge") + version = "${minecraft_version}-${mod_version}-neoforge" + displayName = "${jar_name}-Neoforge-${minecraft_version}-${mod_version}" + } + +} \ No newline at end of file diff --git a/buildSrc/src/main/groovy/multiloader-common.gradle b/buildSrc/src/main/groovy/multiloader-common.gradle index 000d901..f2466a8 100644 --- a/buildSrc/src/main/groovy/multiloader-common.gradle +++ b/buildSrc/src/main/groovy/multiloader-common.gradle @@ -48,6 +48,7 @@ repositories { // Read more about capabilities here: https://docs.gradle.org/current/userguide/component_capabilities.html#sec:declaring-additional-capabilities-for-a-local-component ['apiElements', 'runtimeElements', 'sourcesElements', 'javadocElements'].each { variant -> configurations."$variant".outgoing { + capability("$group:${project.name}:$version") capability("$group:${base.archivesName.get()}:$version") capability("$group:$mod_id-${project.name}-${minecraft_version}:$version") capability("$group:$mod_id:$version") diff --git a/fabric/build.gradle b/fabric/build.gradle index 408314d..04d6b1c 100644 --- a/fabric/build.gradle +++ b/fabric/build.gradle @@ -1,9 +1,6 @@ plugins { id 'multiloader-loader' id 'fabric-loom' - id "com.github.johnrengelman.shadow" version "8.1.1" - id 'net.darkhax.curseforgegradle' - id 'com.modrinth.minotaur' } //Use the existing Neoforge data generator for resource pack data @@ -42,23 +39,21 @@ loom { repositories { - maven { url "https://maven.architectury.dev/" } - // the repository for Cloth Config - maven { url "https://maven.shedaniel.me/" } + maven { url = uri("https://maven.shedaniel.me/") } maven { - url "https://cursemaven.com" + url = uri("https://cursemaven.com") } maven { name = "Mod Menu Maven" - url = "https://maven.terraformersmc.com/" + url = uri("https://maven.terraformersmc.com/") } maven { name = "Fuzs Mod Resources" - url = "https://raw.githubusercontent.com/Fuzss/modresources/main/maven/" + url = uri("https://raw.githubusercontent.com/Fuzss/modresources/main/maven/") } } @@ -72,7 +67,7 @@ dependencies { modImplementation "net.fabricmc:fabric-loader:${rootProject.fabric_loader_version}" - // Fabric API. This is technically optional, but we need this for Forge Config API Port + // Fabric API. This is technically optional, but we need this for Forge Config API Port and Cloth Config modImplementation "net.fabricmc.fabric-api:fabric-api:${rootProject.fabric_api_version}" @@ -91,9 +86,6 @@ dependencies { } modRuntimeOnly("com.terraformersmc:modmenu:${rootProject.mod_menu_version}") -// common(project(path: ":common", configuration: "namedElements")) { transitive false } -// shadowCommon(project(path: ":common", configuration: "transformProductionFabric")) { transitive false } - } /* IntelliJ Project Import @@ -106,72 +98,4 @@ if (System.getProperty("idea.sync.active") == "true") { it.options.annotationProcessorPath = files() } } -} - -//shadowJar { -// exclude "architectury.common.json" -// configurations = [project.configurations.shadowCommon] -// archiveClassifier = "dev-shadow" -//} - -//remapJar { -// injectAccessWidener = true -// inputFile.set shadowJar.archiveFile -// dependsOn shadowJar -// archiveClassifier.set(null) -//} - -//jar { -// archiveClassifier.set("dev") -//} - -//sourcesJar { -// def commonSources = project(":common").sourcesJar -// dependsOn commonSources -// from commonSources.archiveFile.map { zipTree(it) } -//} - -components.java { - withVariantsFromConfiguration(project.configurations.shadowRuntimeElements) { - skip() - } -} - -if (System.getenv().CURSEFORGE_PUBLISH) { - task curseforge(type: net.darkhax.curseforgegradle.TaskPublishCurseForge) { - apiToken = System.getenv().CURSEFORGE_PUBLISH - - def mainFile = upload(curseforge_id_fabric, remapJar) - mainFile.releaseType = 'release' - mainFile.addGameVersion "Fabric" - mainFile.addGameVersion "${minecraft_version}" - mainFile.addGameVersion "Java 21" - mainFile.addGameVersion('Client') - - mainFile.changelog = file("$project.rootDir/changelog.md") - mainFile.changelogType = 'markdown' - - mainFile.addRequirement("fabric-api", "cloth-config") - } -} - - -if (System.getenv().MODRINTH_PUBLISH) { - String fileContents = file("$project.rootDir/changelog.md").text - modrinth { - token = System.getenv().MODRINTH_PUBLISH - projectId = modrinth_id - versionType = "release" - versionName = "${mod_name}-${project.name}-${minecraft_version}" - versionNumber = project.version - uploadFile = remapJar - changelog = fileContents - gameVersions = ["${minecraft_version}"] - loaders = ["fabric"] - - dependencies { - required.project "fabric-api" - required.project "cloth-config" - } - } } \ No newline at end of file diff --git a/forge/build.gradle b/forge/build.gradle index a94a083..74c11ef 100644 --- a/forge/build.gradle +++ b/forge/build.gradle @@ -1,16 +1,19 @@ plugins { id 'multiloader-loader' - id 'net.minecraftforge.gradle' version '[6.0.24,6.2)' - id 'org.spongepowered.mixin' version '0.7-SNAPSHOT' - id "com.github.johnrengelman.shadow" version "7.1.2" - id 'net.darkhax.curseforgegradle' - id 'com.modrinth.minotaur' + id 'net.minecraftforge.gradle' + id 'org.spongepowered.mixin' } mixin { config("${mod_id}.common.mixins.json") } +jar { + manifest { + attributes["MixinConfigs"] = "${mod_id}.common.mixins.json,${mod_id}.forge.mixins.json" + } +} + //Use the existing Neoforge data generator for resource pack data def generatedResources = project(":neoforge").file("src/generated/resources") @@ -21,7 +24,8 @@ sourceSets { } repositories { - maven { url "https://maven.minecraftforge.net/" } + maven { url = uri("https://maven.minecraftforge.net/") } + maven { url = uri("https://repo1.maven.org/maven2/") } } @@ -89,9 +93,6 @@ dependencies { // Hack fix for now, force jopt-simple to be exactly 5.0.4 because Mojang ships that version, but some transitive dependencies request 6.0+ implementation('net.sf.jopt-simple:jopt-simple:5.0.4') { version { strictly '5.0.4' } } -// common(project(path: ":common", configuration: "namedElements")) { transitive false } -// shadowCommon(project(path: ":common", configuration: "transformProductionForge")) { transitive false } - // implementation("me.shedaniel.cloth:cloth-config-forge:${rootProject.cloth_config_version}") //MixinExtras @@ -108,7 +109,6 @@ dependencies { // jarJar.ranged(it, "[${rootProject.forge_config_api_port_version},)") // } - } @@ -125,39 +125,3 @@ sourceSets.each { it.output.resourcesDir = dir it.java.destinationDirectory = dir } - - -if (System.getenv().CURSEFORGE_PUBLISH) { - task curseforge(type: net.darkhax.curseforgegradle.TaskPublishCurseForge) { - apiToken = System.getenv().CURSEFORGE_PUBLISH - - def mainFile = upload(curseforge_id_forge, jar) - mainFile.releaseType = 'release' - mainFile.addGameVersion "Forge" - mainFile.addGameVersion "${minecraft_version}" - mainFile.addGameVersion "Java 21" - mainFile.addGameVersion('Client') - - mainFile.changelog = file("$project.rootDir/changelog.md") - mainFile.changelogType = 'markdown' - - mainFile.addRequirement("configured") - } -} - - -if (System.getenv().MODRINTH_PUBLISH) { - String fileContents = file("$project.rootDir/changelog.md").text - modrinth { - token = System.getenv().MODRINTH_PUBLISH - projectId = project.modrinth_id - versionType = "release" - versionName = "${mod_name}-${project.name}-${minecraft_version}" - versionNumber = project.version - uploadFile = jar - changelog = fileContents - gameVersions = ["${minecraft_version}"] - loaders = ["forge"] - - } -} \ No newline at end of file diff --git a/forge/src/main/java/me/soapsuds/boatiview/forge/config/BConfig.java b/forge/src/main/java/me/soapsuds/boatiview/forge/config/BConfig.java index eefdba9..9c67d32 100644 --- a/forge/src/main/java/me/soapsuds/boatiview/forge/config/BConfig.java +++ b/forge/src/main/java/me/soapsuds/boatiview/forge/config/BConfig.java @@ -25,9 +25,9 @@ public static class Client { public Client(ForgeConfigSpec.Builder builder) { builder.push(BConstants.CONFIG_NAME); - SHOW_HANDS = builder.comment("Toggle whether the item held in hand should be rendered whilst the boat is moving").translation(BTranslationKeys.CONFIG_SHOW_HANDS).define("show_hands", true); + SHOW_HANDS = builder.comment("Toggle whether the item held in hand should be rendered whilst the boat is moving").translation(BTranslationKeys.configOption(BTranslationKeys.CONFIG_SHOW_HANDS)).define("show_hands", true); WHITELISTED_ITEMS = builder.comment("Items that will remain displayed in hand. Adding the character '*' after a Mod ID will include all items from the mod. E.g. 'modid:*'. If no Mod ID is specified before the '*' character, all items will be included. E.g. '*'") - .translation(BTranslationKeys.CONFIG_WHITELIST_ITEMS) + .translation(BTranslationKeys.configOption(BTranslationKeys.CONFIG_WHITELIST_ITEMS)) .defineList("whitelisted_items", Lists.newArrayList("minecraft:filled_map"), String.class::isInstance); builder.pop(); } diff --git a/gradle.properties b/gradle.properties index d2d84b7..63ff2cb 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,6 +1,6 @@ # Gradle # Done to increase the memory available to gradle. -org.gradle.jvmargs=-Xmx1G +org.gradle.jvmargs=-Xmx2G org.gradle.daemon=false #Project @@ -57,14 +57,14 @@ fabric_java_version_range=>=21 yarn_mappings=1.21.4+build.2 #Neoforge -neoforge_version=21.4.19-beta -neoforge_version_range=[21.1.90,) +neoforge_version=21.4.49-beta +neoforge_version_range=[21.4.0-beta,) neoforge_loader_version_range=[4,) neoforge_java_version_range=[21,) #Forge forge_version=54.0.6 -forge_version_range=[53.0.25,) +forge_version_range=[54.0.0,) forge_loader_version_range=[0,) # Common dependencies @@ -82,4 +82,4 @@ configured_version=5919104 #Publishing curseforge_id_forge=482160 curseforge_id_fabric=482444 -modrinth_id=PFwYNrHb \ No newline at end of file +modrinth_id=BdKIyOLe \ No newline at end of file diff --git a/neoforge/build.gradle b/neoforge/build.gradle index 2fee41a..4c173a8 100644 --- a/neoforge/build.gradle +++ b/neoforge/build.gradle @@ -1,9 +1,6 @@ plugins { id 'multiloader-loader' id 'net.neoforged.moddev' - id "com.github.johnrengelman.shadow" version "8.1.1" - id 'net.darkhax.curseforgegradle' - id 'com.modrinth.minotaur' } neoForge { version = rootProject.neoforge_version @@ -50,49 +47,11 @@ sourceSets { } repositories { - maven { url "https://maven.neoforged.net/releases/" } - maven { url "https://maven.architectury.dev/" } + maven { url = uri("https://maven.neoforged.net/releases/") } + maven { url = uri("https://maven.architectury.dev/") } } dependencies { // neoForge "net.neoforged:neoforge:${neoforge_version}" -// -// common(project(path: ":common", configuration: "namedElements")) { transitive false } -// shadowCommon(project(path: ":common", configuration: "transformProductionNeoForge")) { transitive false } -} - -if (System.getenv().CURSEFORGE_PUBLISH) { - task curseforge(type: net.darkhax.curseforgegradle.TaskPublishCurseForge) { - apiToken = System.getenv().CURSEFORGE_PUBLISH - - def mainFile = upload(curseforge_id_forge, jar) - mainFile.releaseType = 'release' - mainFile.addGameVersion "Neoforge" - mainFile.addGameVersion "${minecraft_version}" - mainFile.addGameVersion "Java 21" - mainFile.addGameVersion('Client') - - mainFile.changelog = file("$project.rootDir/changelog.md") - mainFile.changelogType = 'markdown' - - mainFile.addRequirement("configured") - } -} - - -if (System.getenv().MODRINTH_PUBLISH) { - String fileContents = file("$project.rootDir/changelog.md").text - modrinth { - token = System.getenv().MODRINTH_PUBLISH - projectId = project.modrinth_id - versionType = "release" - versionName = "${mod_name}-${project.name}-${minecraft_version}" - versionNumber = project.version - uploadFile = jar - changelog = fileContents - gameVersions = ["${minecraft_version}"] - loaders = ["neoforge"] - - } } \ No newline at end of file diff --git a/neoforge/src/main/java/me/soapsuds/boatiview/neoforge/BoatItemViewImpl.java b/neoforge/src/main/java/me/soapsuds/boatiview/neoforge/BoatItemViewImpl.java index a15e5ae..f2bb6bc 100644 --- a/neoforge/src/main/java/me/soapsuds/boatiview/neoforge/BoatItemViewImpl.java +++ b/neoforge/src/main/java/me/soapsuds/boatiview/neoforge/BoatItemViewImpl.java @@ -12,7 +12,6 @@ import net.neoforged.fml.config.ModConfig; import net.neoforged.neoforge.client.gui.ConfigurationScreen; import net.neoforged.neoforge.client.gui.IConfigScreenFactory; -import net.neoforged.neoforge.common.data.ExistingFileHelper; import net.neoforged.neoforge.data.event.GatherDataEvent; @@ -31,7 +30,6 @@ public BoatItemViewImpl(IEventBus modEventBus, ModContainer modContainer, Dist d public void onGatherData(GatherDataEvent.Client e) { DataGenerator generator = e.getGenerator(); - ExistingFileHelper existingFileHelper = e.getExistingFileHelper(); generator.addProvider(true, new BEnglishLangGen(generator.getPackOutput())); generator.addProvider(true, new BChineseChinaLangGen(generator.getPackOutput())); generator.addProvider(true, new BFrenchFranceLangGen(generator.getPackOutput()));