From d7e371152f28e04ba6f5363f0ba79ffc6a68b3d5 Mon Sep 17 00:00:00 2001 From: TexTrue <3140846162@qq.com> Date: Wed, 7 Aug 2024 14:57:05 +0800 Subject: [PATCH] rework build script --- .github/workflows/build.yml | 28 ++----- CHANGELOG.md | 11 +-- build.gradle | 36 ++++----- common/build.gradle | 14 ---- fabric/build.gradle | 36 +++------ forge/build.gradle | 74 ------------------- forge/gradle.properties | 1 - .../forge/ModPlatformImpl.java | 9 --- .../forge/VMTranslationUpdateClientForge.java | 47 ------------ forge/src/main/resources/pack.mcmeta | 6 -- gradle.properties | 4 +- neoforge/build.gradle | 36 +++------ .../src/main/resources/META-INF/mods.toml | 6 +- settings.gradle | 1 - 14 files changed, 49 insertions(+), 260 deletions(-) delete mode 100644 forge/build.gradle delete mode 100644 forge/gradle.properties delete mode 100644 forge/src/main/java/top/vmctcn/vmtranslationupdate/forge/ModPlatformImpl.java delete mode 100644 forge/src/main/java/top/vmctcn/vmtranslationupdate/forge/VMTranslationUpdateClientForge.java delete mode 100644 forge/src/main/resources/pack.mcmeta diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index d0da251..d8474c5 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -32,26 +32,12 @@ jobs: chmod +x gradlew ./gradlew mergeJars - - name: Upload artifacts (fabric) + - name: Upload artifacts uses: actions/upload-artifact@v4 with: - name: fabric - path: ${{ github.workspace }}/fabric/build/libs - - - name: Upload artifacts (forge) - uses: actions/upload-artifact@v4 - with: - name: forge - path: ${{ github.workspace }}/forge/build/libs - - - name: Upload artifacts (neoforge) - uses: actions/upload-artifact@v4 - with: - name: neoforge - path: ${{ github.workspace }}/neoforge/build/libs - - - name: Upload artifacts (Forgix merged jar) - uses: actions/upload-artifact@v4 - with: - name: merged - path: ${{ github.workspace }}/build/libs/forgix \ No newline at end of file + name: artifacts + path: | + ${{ github.workspace }}/fabric/build/libs + ${{ github.workspace }}/forge/build/libs + ${{ github.workspace }}/neoforge/build/libs + ${{ github.workspace }}/build/merged \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index ae22d36..0f7bfd6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,11 +1,2 @@ ## Changelog -- use native api -- fix mod publish -- add mod info translation (Only Fabric & NeoForge) -- new icon - -## Changelog -- 使用加载器本地API (不再使用Architectury API) -- 修复模组上传问题 -- 添加模组信息翻译 (仅Fabric & NeoForge) -- 新图标 \ No newline at end of file +- forgix -> modfusioner \ No newline at end of file diff --git a/build.gradle b/build.gradle index 8245d2b..a266eaf 100644 --- a/build.gradle +++ b/build.gradle @@ -3,7 +3,7 @@ plugins { id "dev.architectury.loom" version "1.6-SNAPSHOT" apply false id "com.github.johnrengelman.shadow" version "8.+" apply false id "com.hypherionmc.modutils.modpublisher" version "2.+" - id "io.github.pacifistmc.forgix" version "1.+" + id "com.hypherionmc.modutils.modfusioner" version "1.0.+" } architectury { @@ -42,29 +42,23 @@ allprojects { } } -forgix { - group = rootProject.maven_group - mergedJarName = "${rootProject.archives_base_name}-${rootProject.version}.jar" - outputDir = "build/libs/forgix" +fusioner { + packageGroup = rootProject.maven_group + mergedJarName = "${rootProject.archives_base_name}" + outputDirectory = "build/merged" + jarVersion = rootProject.version - forge { - projectName = "forge" - jarLocation = "build/libs/${rootProject.archives_base_name}-forge-${rootProject.version}.jar" + neoforge { + projectName = "neoforge" + inputTaskName = "remapJar" } fabric { projectName = "fabric" - jarLocation = "build/libs/${rootProject.archives_base_name}-fabric-${rootProject.version}.jar" - } - - custom { - projectName = "neoforge" - jarLocation = "build/libs/${rootProject.archives_base_name}-neoforge-${ rootProject.version }.jar" + inputTaskName = "remapJar" } } -mergeJars.dependsOn(build) - publisher { apiKeys { curseforge(System.getenv("CURSEFORGE_TOKEN")) @@ -76,11 +70,11 @@ publisher { versionType = "release" changelog = file("CHANGELOG.md").getText('UTF-8') version = "$rootProject.version" - displayName = "VM Translation Update 1.20~1.20.4 ${rootProject.mod_version}" - gameVersions = ["1.20", "1.20.1", "1.20.2", "1.20.3", "1.20.4"] + displayName = "VM Translation Update 1.20.4 ${rootProject.mod_version}" + gameVersions = ["1.20.4"] curseEnvironment = "client" - loaders = ["fabric", "quilt", "forge", "neoforge"] - artifact = (forgix.getOutputDir() + "/" + forgix.getMergedJarName()) + loaders = ["fabric", "quilt", "neoforge"] + artifact = fusejars modrinthDepends { required "cloth-config" @@ -90,5 +84,3 @@ publisher { required "cloth-config" } } - -publishMod.dependsOn(mergeJars) diff --git a/common/build.gradle b/common/build.gradle index cd2ea62..012b85c 100644 --- a/common/build.gradle +++ b/common/build.gradle @@ -8,17 +8,3 @@ dependencies { modImplementation "net.fabricmc:fabric-loader:${rootProject.fabric_loader_version}" modApi "me.shedaniel.cloth:cloth-config:${rootProject.clothconfig_version}" } - -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/fabric/build.gradle b/fabric/build.gradle index caedbcf..1c0885a 100644 --- a/fabric/build.gradle +++ b/fabric/build.gradle @@ -6,11 +6,17 @@ architectury { project.archivesBaseName = rootProject.archivesBaseName + "-fabric" configurations { - common - shadowCommon // Don't use shadow from the shadow plugin because we don't want IDEA to index this. + common { + canBeResolved = true + canBeConsumed = false + } compileClasspath.extendsFrom common runtimeClasspath.extendsFrom common developmentFabric.extendsFrom common + shadowBundle { + canBeResolved = true + canBeConsumed = false + } } repositories { @@ -25,7 +31,7 @@ dependencies { modApi("com.terraformersmc:modmenu:${rootProject.modmenu_version}") { transitive false } common(project(path: ":common", configuration: "namedElements")) { transitive false } - shadowCommon(project(path: ":common", configuration: "transformProductionFabric")) { transitive false } + shadowBundle(project(path: ":common", configuration: "transformProductionFabric")) { transitive false } } processResources { @@ -39,12 +45,12 @@ processResources { shadowJar { exclude "architectury.common.json" - configurations = [project.configurations.shadowCommon] + configurations = [project.configurations.shadowBundle] archiveClassifier.set("dev-shadow") } remapJar { - input.set shadowJar.archiveFile + inputFile.set shadowJar.archiveFile dependsOn shadowJar archiveClassifier.set(null) } @@ -58,23 +64,3 @@ sourcesJar { dependsOn commonSources from commonSources.archiveFile.map { zipTree(it) } } - -components.java { - withVariantsFromConfiguration(project.configurations.shadowRuntimeElements) { - skip() - } -} - -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. - } -} diff --git a/forge/build.gradle b/forge/build.gradle deleted file mode 100644 index 9fb5188..0000000 --- a/forge/build.gradle +++ /dev/null @@ -1,74 +0,0 @@ -architectury { - platformSetupLoomIde() - forge() -} - -project.archivesBaseName = rootProject.archivesBaseName + "-forge" - -configurations { - common - shadowCommon // Don't use shadow from the shadow plugin because we don't want IDEA to index this. - compileClasspath.extendsFrom common - runtimeClasspath.extendsFrom common - developmentForge.extendsFrom common -} - -dependencies { - forge "net.minecraftforge:forge:${rootProject.forge_version}" - modApi "me.shedaniel.cloth:cloth-config-forge:${rootProject.clothconfig_version}" - - common(project(path: ":common", configuration: "namedElements")) { transitive false } - shadowCommon(project(path: ":common", configuration: "transformProductionForge")) { transitive = false } -} - -processResources { - inputs.property "version", project.version - - filesMatching("META-INF/mods.toml") { - expand "version": project.version - } -} - -shadowJar { - exclude "fabric.mod.json" - exclude "architectury.common.json" - - configurations = [project.configurations.shadowCommon] - archiveClassifier.set("dev-shadow") -} - -remapJar { - input.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() - } -} - -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. - } -} diff --git a/forge/gradle.properties b/forge/gradle.properties deleted file mode 100644 index 32f842a..0000000 --- a/forge/gradle.properties +++ /dev/null @@ -1 +0,0 @@ -loom.platform=forge \ No newline at end of file diff --git a/forge/src/main/java/top/vmctcn/vmtranslationupdate/forge/ModPlatformImpl.java b/forge/src/main/java/top/vmctcn/vmtranslationupdate/forge/ModPlatformImpl.java deleted file mode 100644 index 0c6e40b..0000000 --- a/forge/src/main/java/top/vmctcn/vmtranslationupdate/forge/ModPlatformImpl.java +++ /dev/null @@ -1,9 +0,0 @@ -package top.vmctcn.vmtranslationupdate.forge; - -import net.minecraftforge.fml.ModList; - -public class ModPlatformImpl { - public static boolean isModLoaded(String modid) { - return ModList.get().isLoaded(modid); - } -} diff --git a/forge/src/main/java/top/vmctcn/vmtranslationupdate/forge/VMTranslationUpdateClientForge.java b/forge/src/main/java/top/vmctcn/vmtranslationupdate/forge/VMTranslationUpdateClientForge.java deleted file mode 100644 index 75fe48f..0000000 --- a/forge/src/main/java/top/vmctcn/vmtranslationupdate/forge/VMTranslationUpdateClientForge.java +++ /dev/null @@ -1,47 +0,0 @@ -package top.vmctcn.vmtranslationupdate.forge; - -import me.shedaniel.autoconfig.AutoConfig; -import net.minecraft.client.MinecraftClient; -import net.minecraft.server.network.ServerPlayerEntity; -import net.minecraftforge.client.ConfigScreenHandler; -import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.event.TickEvent; -import net.minecraftforge.event.entity.player.PlayerEvent; -import net.minecraftforge.eventbus.api.EventPriority; -import net.minecraftforge.eventbus.api.IEventBus; -import net.minecraftforge.fml.IExtensionPoint; -import net.minecraftforge.fml.ModLoadingContext; -import net.minecraftforge.fml.common.Mod; -import net.minecraftforge.fml.loading.FMLLoader; -import top.vmctcn.vmtranslationupdate.ModEvents; -import top.vmctcn.vmtranslationupdate.VMTranslationUpdate; -import top.vmctcn.vmtranslationupdate.config.ModConfigs; -import top.vmctcn.vmtranslationupdate.util.ModConfigUtil; - -@Mod(VMTranslationUpdate.MOD_ID) -public class VMTranslationUpdateClientForge { - public VMTranslationUpdateClientForge() { - IEventBus forgeEventBus = MinecraftForge.EVENT_BUS; - ModLoadingContext context = ModLoadingContext.get(); - - context.registerExtensionPoint(IExtensionPoint.DisplayTest.class, () -> new IExtensionPoint.DisplayTest(() -> IExtensionPoint.DisplayTest.IGNORESERVERONLY, (a, b) -> true)); - context.registerExtensionPoint(ConfigScreenHandler.ConfigScreenFactory.class, () -> new ConfigScreenHandler.ConfigScreenFactory((client, screen) -> AutoConfig.getConfigScreen(ModConfigs.class, screen).get())); - - if (FMLLoader.getDist().isClient()) { - VMTranslationUpdate.init(); - - forgeEventBus.addListener(EventPriority.HIGHEST, event -> { - MinecraftClient client = MinecraftClient.getInstance(); - - if (event.phase == TickEvent.Phase.END && ModConfigUtil.getConfig().displayTips) { - if (client.player == null) return; - ModEvents.clientTickEndEvent(client); - } - }); - - forgeEventBus.addListener(EventPriority.HIGHEST, event -> { - ModEvents.playerJoinEvent((ServerPlayerEntity) event.getEntity()); - }); - } - } -} diff --git a/forge/src/main/resources/pack.mcmeta b/forge/src/main/resources/pack.mcmeta deleted file mode 100644 index 281bccd..0000000 --- a/forge/src/main/resources/pack.mcmeta +++ /dev/null @@ -1,6 +0,0 @@ -{ - "pack": { - "description": "VM Translation Update", - "pack_format": 8 - } -} diff --git a/gradle.properties b/gradle.properties index 48b4159..ee69616 100644 --- a/gradle.properties +++ b/gradle.properties @@ -5,7 +5,7 @@ enabled_platforms=fabric,forge,neoforge yarn_mappings=1.20.4+build.3 archives_base_name=VMTranslationUpdate -mod_version=2.4.0 +mod_version=3.0.1 maven_group=top.vmctcn.vmtranslationupdate clothconfig_version=13.0.121 @@ -16,7 +16,7 @@ modmenu_version=9.2.0-beta.2 forge_version=1.20.4-49.0.50 -neoforge_version=20.4.234 +neoforge_version=20.4.237 curseforge_id=890229 modrinth_id=wvCSIW08 diff --git a/neoforge/build.gradle b/neoforge/build.gradle index 5f37a61..9245706 100644 --- a/neoforge/build.gradle +++ b/neoforge/build.gradle @@ -6,11 +6,17 @@ architectury { project.archivesBaseName = rootProject.archivesBaseName + "-neoforge" configurations { - common - shadowCommon // Don't use shadow from the shadow plugin because we don't want IDEA to index this. + common { + canBeResolved = true + canBeConsumed = false + } compileClasspath.extendsFrom common runtimeClasspath.extendsFrom common developmentNeoForge.extendsFrom common + shadowBundle { + canBeResolved = true + canBeConsumed = false + } } repositories { @@ -22,7 +28,7 @@ dependencies { modApi "me.shedaniel.cloth:cloth-config-neoforge:${rootProject.clothconfig_version}" common(project(path: ":common", configuration: "namedElements")) { transitive false } - shadowCommon(project(path: ":common", configuration: "transformProductionNeoForge")) { transitive = false } + shadowBundle(project(path: ":common", configuration: "transformProductionNeoForge")) { transitive = false } } processResources { @@ -37,12 +43,12 @@ shadowJar { exclude "fabric.mod.json" exclude "architectury.common.json" - configurations = [project.configurations.shadowCommon] + configurations = [project.configurations.shadowBundle] archiveClassifier.set("dev-shadow") } remapJar { - input.set shadowJar.archiveFile + inputFile.set shadowJar.archiveFile dependsOn shadowJar archiveClassifier.set(null) } @@ -56,23 +62,3 @@ sourcesJar { dependsOn commonSources from commonSources.archiveFile.map { zipTree(it) } } - -components.java { - withVariantsFromConfiguration(project.configurations.shadowRuntimeElements) { - skip() - } -} - -publishing { - publications { - mavenNeoForge(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. - } -} diff --git a/neoforge/src/main/resources/META-INF/mods.toml b/neoforge/src/main/resources/META-INF/mods.toml index 9c4f304..ea73776 100644 --- a/neoforge/src/main/resources/META-INF/mods.toml +++ b/neoforge/src/main/resources/META-INF/mods.toml @@ -17,14 +17,14 @@ logoFile = "icon.png" [[dependencies.vmtranslationupdate]] modId = "minecraft" -mandatory = true -versionRange = "[1.20,)" +type = "required" +versionRange = "[1.20.1,)" ordering = "NONE" side = "BOTH" [[dependencies.vmtranslationupdate]] modId = "cloth_config" -mandatory = true +type = "required" versionRange = "*" ordering = "AFTER" side = "BOTH" \ No newline at end of file diff --git a/settings.gradle b/settings.gradle index abd5c38..fbe0953 100644 --- a/settings.gradle +++ b/settings.gradle @@ -11,7 +11,6 @@ pluginManagement { include("common") include("fabric") -include("forge") include("neoforge") rootProject.name = "VMTranslationUpdate"