From 93561a5b2f006decd85a87a4e3179ede408519eb Mon Sep 17 00:00:00 2001 From: DL909 Date: Thu, 30 Jul 2026 21:06:12 +0800 Subject: [PATCH] chore: migrate to mod-publish-plugin chore: update Jenkinsfile (now shares the same Jenkinsfile with 1.21) --- Common/build.gradle | 1 - Fabric/build.gradle | 73 ++++++++++++++++++++++++++-------------- Forge/build.gradle | 48 +++++++++++++++++---------- Jenkinsfile | 40 ++++++++++++++++------ build.gradle | 81 ++++++++++++++++++--------------------------- settings.gradle | 1 + 6 files changed, 142 insertions(+), 102 deletions(-) diff --git a/Common/build.gradle b/Common/build.gradle index aca1334466..756b3f891a 100644 --- a/Common/build.gradle +++ b/Common/build.gradle @@ -1,6 +1,5 @@ plugins { id 'org.spongepowered.gradle.vanilla' version '0.2.1-SNAPSHOT' - id "at.petra-k.pkpcpbp.PKSubprojPlugin" } minecraft { diff --git a/Fabric/build.gradle b/Fabric/build.gradle index 9cc6b1b0e1..b2d58cf702 100644 --- a/Fabric/build.gradle +++ b/Fabric/build.gradle @@ -1,30 +1,55 @@ plugins { id 'fabric-loom' version "1.9+" - id "at.petra-k.pkpcpbp.PKSubprojPlugin" } -pkSubproj { - pkPublish = true - curseforgeJar = remapJar.archiveFile - curseforgeDependencies([ - "paucal", - "patchouli", - "fabric-language-kotlin", - "inline", - "cloth-config", - "cardinal-components-api", - "fabric-api", - ]) - modrinthJar = remapJar.archiveFile - modrinthDependencies([ - "paucal:dabyDTwJ", // 0.6.0-fabric - "patchouli:1.20.1-80-fabric", - "fabric-language-kotlin:1.13.7+kotlin.2.2.21", - "inline:1.20.1-1.2.2-fabric", - "cloth-config:11.1.106+fabric", - "cardinal-components-api:5.2.1", - "fabric-api:0.84.0+1.20.1", - ]) +publishMods { + // for Fabric 1.21.11 and below + file = remapJar.archiveFile + modLoaders.add("fabric") + curseforge{ + requires( + "paucal", + "patchouli", + "fabric-language-kotlin", + "inline", + "cloth-config", + "cardinal-components-api", + "fabric-api", + ) + } + modrinth{ + requires { + slug = "paucal" + version = "dabyDTwJ" // 0.6.0 fabric ver + } + requires { + slug = "patchouli" + version = "1.20.1-80-fabric" + } + + requires { + slug = "fabric-language-kotlin" + version = fabricLanguageKotlinVersion + } + + requires { + slug = "inline" + version = "1.20.1-1.2.2-fabric" + } + + requires { + slug = "cloth-config" + version = clothConfigVersion + "+fabric" + } + requires { + slug = "cardinal-components-api" + version = cardinalComponentsVersion + } + requires { + slug = "fabric-api" + version = fabricVersion + } + } } loom { @@ -143,7 +168,7 @@ dependencies { // modImplementation "maven.modrinth:phosphor:${phosphorVersion}" } -tasks.withType(JavaCompile) { +tasks.withType(JavaCompile).configureEach { source(project(":Common").sourceSets.main.allSource) } compileKotlin { diff --git a/Forge/build.gradle b/Forge/build.gradle index 43831992c4..b33b6c84a4 100644 --- a/Forge/build.gradle +++ b/Forge/build.gradle @@ -16,29 +16,41 @@ buildscript { plugins { id "java" id "maven-publish" - - id "at.petra-k.pkpcpbp.PKSubprojPlugin" } apply plugin: 'net.minecraftforge.gradle' apply plugin: 'org.spongepowered.mixin' -pkSubproj { - pkPublish = true - curseforgeJar = jar.archiveFile - curseforgeDependencies([ - "paucal", - "patchouli", - "caelus", - "inline", - ]) - modrinthJar = jar.archiveFile - modrinthDependencies([ - "paucal:HyBiJPtT", // 0.6.0-forge - "patchouli:1.20.1-80-forge", - "caelus:3.1.0+1.20", - "inline:1.20.1-1.2.2-forge", - ]) +publishMods { + file = jar.archiveFile + modLoaders.add("neoForge") + curseforge{ + requires( + "paucal", + "patchouli", + "caelus", + "inline" + ) + } + modrinth{ + requires { + slug = "paucal" + version = "HyBiJPtT" + platform = "neoforge" + } + requires { + slug = "patchouli" + version = "1.20.1-80-forge" + } + requires { + slug = "caelus" + version = "3.1.0+1.20" + } + requires { + slug = "inline" + version = "1.20.1-1.2.2-forge" + } + } } repositories { diff --git a/Jenkinsfile b/Jenkinsfile index a2da4ee85f..e3be4436de 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,14 +1,29 @@ #!/usr/bin/env groovy +RELEASE_BRANCHES = ["main", "1.21"] + pipeline { agent any tools { - jdk "jdk-17.0.1" + jdk "jdk-21" + } + parameters { + booleanParam( + name: "PUBLISH_CURSEFORGE_AND_MODRINTH", + description: "Publish to CurseForge and modrinth", + defaultValue: false, + ) + booleanParam( + name: "FORMAL_RELEASE", + description: "decides if is a formal release (without -pre)", + defaultValue: false, + ) } environment { discordWebhook = credentials('discordWebhook') CURSEFORGE_TOKEN = credentials('curseforgeApiKey') MODRINTH_TOKEN = credentials('modrinthApiKey') + FORMAL_RELEASE = "${params.FORMAL_RELEASE ? 'true' : 'false'}" } stages { stage('Clean') { @@ -43,7 +58,7 @@ pipeline { stage('Publish') { when { allOf { - branch 'main' + expression { env.BRANCH_NAME in RELEASE_BRANCHES } not { changeRequest() } } } @@ -51,23 +66,26 @@ pipeline { stage('Deploy Previews') { steps { echo 'Deploying previews to various places' - sh './gradlew publish publishToDiscord' + sh './gradlew publish announceDiscord' } } stage('Deploy releases') { + when { + expression { params.CURSEFORGE_AND_MODRINTH} + } steps { echo 'Maybe deploy releases' sh './gradlew publishCurseforge publishModrinth' } - } - } + }} } } - post { - always { - archiveArtifacts 'Common/build/libs/**.jar' - archiveArtifacts 'Forge/build/libs/**.jar' - archiveArtifacts 'Fabric/build/libs/**.jar' - } +} +post { + always { + archiveArtifacts 'Common/build/libs/**.jar' + archiveArtifacts 'Neoforge/build/libs/**.jar' + archiveArtifacts 'Fabric/build/libs/**.jar' } +} } \ No newline at end of file diff --git a/build.gradle b/build.gradle index 97cab8aa70..736470f45c 100644 --- a/build.gradle +++ b/build.gradle @@ -1,5 +1,3 @@ -import at.petrak.pkpcpbp.MiscUtil - buildscript { repositories { mavenCentral() @@ -19,61 +17,36 @@ plugins { // Also it looks like property lookups don't work this early id 'fabric-loom' version '1.9+' apply false - id("at.petra-k.pkpcpbp.PKPlugin") version "0.2.0-pre-104" - id("at.petra-k.pkpcpbp.PKSubprojPlugin") version "0.2.0-pre-104" apply false id("at.petra-k.pkpcpbp.PKJson5Plugin") version "0.2.0-pre-104" apply false + id "me.modmuss50.mod-publish-plugin" } repositories { mavenCentral() } -pkpcpbp { - // if something goes wrong in CI, make sure we can see the logs to figure out why - superDebugInfo = System.getenv("CI") != null - // we set the maven coordinates manually in the subprojects block - doProjectMetadata = false - setupJarMetadata = true - setupMavenMetadata = true - javaVersion = 17 - modInfo { - modID = project.modID - mcVersion = project.minecraftVersion - modVersion = project.modVersion - } - curseforgeInfo { - id = 569849 - stability = "beta" - token = System.getenv("CURSEFORGE_TOKEN") - } - modrinthInfo { - id = "nTW3yKrm" - stability = "beta" - token = System.getenv("MODRINTH_TOKEN") - } -} - -subprojects { +subprojects {subproject-> apply plugin: 'java' apply plugin: 'kotlin' apply plugin: 'maven-publish' - apply plugin: 'at.petra-k.pkpcpbp.PKSubprojPlugin' apply plugin: 'at.petra-k.pkpcpbp.PKJson5Plugin' + if(subproject.path != ":Common") { + apply plugin: 'me.modmuss50.mod-publish-plugin' + } group = "at.petra-k.$modID" base.archivesName = "$modID-$platform-$minecraftVersion" version = modVersion - def isRelease = MiscUtil.isRelease(MiscUtil.getMostRecentPush(project)) + def isRelease = project.hasProperty('isRelease') ? + project.property('isRelease').toBoolean() : false def buildNumber = System.getenv("BUILD_NUMBER") if (!isRelease && buildNumber != null) { version += "-pre-$buildNumber" } - pkSubproj { - platform = project.platform - artifactId = base.archivesName.get() - versionDisplayName = "$platform-$minecraftVersion-$modVersion" + kotlin { + jvmToolchain(17) } pkJson5 { @@ -86,21 +59,10 @@ subprojects { it.options.release = 17 } - compileKotlin { - kotlinOptions { - jvmTarget = "17" - } - } - compileTestKotlin { - kotlinOptions { - jvmTarget = "17" - } - } - // Disables Gradle's custom module metadata from being published to maven. The // metadata includes mapped dependencies which are not reasonably consumable by // other mod developers. - tasks.withType(GenerateModuleMetadata) { + tasks.withType(GenerateModuleMetadata).configureEach { enabled = false } @@ -116,6 +78,29 @@ subprojects { sourcesJar { duplicatesStrategy 'exclude' } + + if(subproject.path != ":Common") { + publishMods { + type = BETA + changelog = "" + + modrinth { + accessToken = providers.environmentVariable("MODRINTH_TOKEN") + projectId = "nTW3yKrm" + minecraftVersions.add("1.21.1") + } + curseforge { + accessToken = providers.environmentVariable("CURSEFORGE_TOKEN") + projectId = "569849" + minecraftVersions.add("1.21.1") + client = true + server = true + } + discord { + webhookUrl = providers.environmentVariable("discordWebhook") + } + } + } } allprojects { diff --git a/settings.gradle b/settings.gradle index 67a39ad9c4..70c53b1558 100644 --- a/settings.gradle +++ b/settings.gradle @@ -14,6 +14,7 @@ pluginManagement { plugins { id "org.jetbrains.kotlin.jvm" version kotlinVersion + id "me.modmuss50.mod-publish-plugin" version "2.1.1" } }