From 3c8faec71a1734eebe2b14eafa98d784fb3a8610 Mon Sep 17 00:00:00 2001 From: Rhys <98863820+rhysdh540@users.noreply.github.com> Date: Mon, 29 Apr 2024 22:18:13 -0400 Subject: [PATCH] miscellaneous improvements cant believe i spelled miscellaneous right first try --- api/src/main/resources/icon.png | Bin 167 -> 715 bytes api/src/main/resources/icon_large.png | Bin 715 -> 0 bytes build.gradle.kts | 32 +++++++- .../dev/nolij/zumegradle/JarCompressing.kt | 74 ++++++------------ gradle.properties | 2 +- icon_padded.png | Bin 4589 -> 158 bytes icon_padded_large.png | Bin 6753 -> 842 bytes .../src/main/resources/META-INF/mods.toml | 2 +- .../src/main/resources/META-INF/mods.toml | 2 +- .../src/main/resources/META-INF/mods.toml | 2 +- .../src/main/resources/META-INF/mods.toml | 2 +- .../resources/META-INF/neoforge.mods.toml | 2 +- proguard.pro | 36 +++++++++ src/main/resources/META-INF/mods.toml | 2 +- src/main/resources/mcmod.info | 2 +- vintage/src/main/resources/mcmod.info | 2 +- 16 files changed, 101 insertions(+), 59 deletions(-) delete mode 100644 api/src/main/resources/icon_large.png create mode 100644 proguard.pro diff --git a/api/src/main/resources/icon.png b/api/src/main/resources/icon.png index a8c0d3cdc44bd223e31acfcb1e43b1ba40dfbce9..9463d529dcff7f4d283b4a8fe5988c697445b46d 100644 GIT binary patch literal 715 zcmeAS@N?(olHy`uVBq!ia0y~yU;;9k7+9Er6kFKIlR!!?z$e6Y&YU^^{{B%>QFG>O z@bdCHefy8Iv-9k=+ih%YEG#VCT)!^`YRm9+aSW-r_4b0NU~>QitD{Z=BX>kcYs3L3 zodm_a;(GH}@2ASKUygpQ;yDS9z8wPE0S5+la3%`FVv&pm_wB{uEGVK_IT`maKP>+u z@}vu^EUMt+cKeHwJFS^6SfPqz;VrPiB1j{l1HTmBwlfko+6DhG;2%c`I*IK4mtAApSlS# z-#ESNcAdCjJmdH918v)w|Ah#>nIgn=!_-R0Vu7#31vQ=wW;Wg%3pF diff --git a/api/src/main/resources/icon_large.png b/api/src/main/resources/icon_large.png deleted file mode 100644 index 9463d529dcff7f4d283b4a8fe5988c697445b46d..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 715 zcmeAS@N?(olHy`uVBq!ia0y~yU;;9k7+9Er6kFKIlR!!?z$e6Y&YU^^{{B%>QFG>O z@bdCHefy8Iv-9k=+ih%YEG#VCT)!^`YRm9+aSW-r_4b0NU~>QitD{Z=BX>kcYs3L3 zodm_a;(GH}@2ASKUygpQ;yDS9z8wPE0S5+la3%`FVv&pm_wB{uEGVK_IT`maKP>+u z@}vu^EUMt+cKeHwJFS^6SfPqz;VrPiB1j{l1HTmBwlfko+("compressJar") { jarShrinkingType = releaseChannel.deflation classShrinkingType = releaseChannel.classes jsonShrinkingType = releaseChannel.json - useProguard(uniminedImpls.flatMap { implName -> project(":$implName").unimined.minecrafts.values }) + if(releaseChannel.proguard) { + useProguard(uniminedImpls.flatMap { implName -> project(":$implName").unimined.minecrafts.values }) + } } afterEvaluate { @@ -528,4 +537,23 @@ afterEvaluate { } } } +} + +fun removeDuplicateEntries(zip: File) { + val contents = linkedMapOf() + ZipFile(zip).use { + it.entries().asIterator().forEach { entry -> + if(!entry.isDirectory) + contents[entry.name] = it.getInputStream(entry).readAllBytes() + } + } + zip.delete() + ZipOutputStream(zip.outputStream()).use { out -> + contents.forEach { (name, bytes) -> + out.putNextEntry(ZipEntry(name)) + out.write(bytes) + out.closeEntry() + } + out.finish() + } } \ No newline at end of file diff --git a/buildSrc/src/main/kotlin/dev/nolij/zumegradle/JarCompressing.kt b/buildSrc/src/main/kotlin/dev/nolij/zumegradle/JarCompressing.kt index 0a9dfdc0..d80147b4 100644 --- a/buildSrc/src/main/kotlin/dev/nolij/zumegradle/JarCompressing.kt +++ b/buildSrc/src/main/kotlin/dev/nolij/zumegradle/JarCompressing.kt @@ -39,8 +39,8 @@ enum class ClassShrinkingType { STRIP_ALL, ; - fun shouldStripLVTs() = this == STRIP_LVTS || this == STRIP_ALL - fun shouldStripSourceFiles() = this == STRIP_SOURCE_FILES || this == STRIP_ALL + fun shouldStripLVTs() = this.ordinal % 2 == 1 + fun shouldStripSourceFiles() = this.ordinal >= 2 fun shouldRun() = this != STRIP_NONE } @@ -70,7 +70,7 @@ fun squishJar(jar: File, classProcessing: ClassShrinkingType, jsonProcessing: Js bytes = when (jsonProcessing) { JsonShrinkingType.MINIFY -> JsonOutput.toJson(json.parse(bytes)).toByteArray() JsonShrinkingType.PRETTY_PRINT -> JsonOutput.prettyPrint(JsonOutput.toJson(json.parse(bytes))).toByteArray() - else -> bytes + else -> throw AssertionError() } } @@ -83,7 +83,6 @@ fun squishJar(jar: File, classProcessing: ClassShrinkingType, jsonProcessing: Js out.closeEntry() } out.finish() - out.close() } } @@ -138,43 +137,22 @@ fun deflate(zip: File, type: JarShrinkingType) { val JAVA_HOME = System.getProperty("java.home") @Suppress("UnstableApiUsage") -fun applyProguard(outputJar: File, minecraftConfigs: List) { - val inputJar = outputJar.copyTo( - outputJar.parentFile.resolve("${outputJar.nameWithoutExtension}_.jar"), true) - inputJar.deleteOnExit() +fun applyProguard(jar: File, minecraftConfigs: List, configDir: File) { + val inputJar = jar.copyTo( + jar.parentFile.resolve("${jar.nameWithoutExtension}_.jar"), true).also { + it.deleteOnExit() + } - val proguardCommand = ArrayList() - proguardCommand.addAll(arrayOf( - "-ignorewarnings", "-dontnote", - "-optimizationpasses", "10", - "-optimizations", "!class/merging/*,!method/marking/private", - "-allowaccessmodification", - "-optimizeaggressively", - "-overloadaggressively", - "-repackageclasses", "dev.nolij.zume", - "-printmapping", outputJar.parentFile.resolve("${outputJar.nameWithoutExtension}-mappings.txt").absolutePath, + val config = configDir.resolve("proguard.pro") + if (!config.exists()) { + error("proguard.pro not found") + } + val proguardCommand = mutableListOf( + "@${config.absolutePath}", + "-printmapping", jar.parentFile.resolve("${jar.nameWithoutExtension}-mappings.txt").absolutePath, "-injars", inputJar.absolutePath, - "-outjars", outputJar.absolutePath, - "-keepattributes", "Runtime*Annotations", // keep annotations - "-keep,allowoptimization", "public class dev.nolij.zume.api.** { public *; }", // public APIs - "-keepclassmembers", "class dev.nolij.zume.impl.config.ZumeConfigImpl { public ; }", // dont rename config fields - "-keep,allowoptimization", "class dev.nolij.zume.ZumeMixinPlugin", // dont rename mixin plugin - "-keep", "class dev.nolij.zume.mixin.** { *; }", // dont touch mixins - "-keep,allowobfuscation,allowoptimization", "@*.*.fml.common.Mod class dev.nolij.zume.** { " + // Forge entrypoints - "public (...); " + - "@*.*.fml.common.Mod\$EventHandler ; " + - "@*.*.fml.common.eventhandler.SubscribeEvent ; }", - "-keepclassmembers,allowoptimization", "class dev.nolij.zume.** { " + // screens - "public void render(int,int,float); " + - "public void tick(); " + - "public void init(); }", - "-keepclassmembers,allowoptimization", "class dev.nolij.zume.** extends net.minecraft.client.gui.screens.Screen { public *; }", - "-keep,allowoptimization", "class dev.nolij.zume.** implements *.*.fml.client.IModGuiFactory", // Legacy Forge config providers - "-keep,allowoptimization", "class dev.nolij.zume.FabricZumeBootstrapper", // referenced in FMJ - "-keep,allowoptimization", "class dev.nolij.zume.modern.integration.ZumeModMenuIntegration", // referenced in FMJ - "-keep,allowoptimization", "class dev.nolij.zume.primitive.event.KeyBindingRegistrar { public *; }", // referenced in FMJ - "-keep,allowoptimization", "class io.github.prospector.modmenu.** { *; }", // ugly classloader hack - )) + "-outjars", jar.absolutePath, + ) val libraries = HashSet() libraries.add("${JAVA_HOME}/jmods/java.base.jmod") @@ -205,7 +183,7 @@ fun applyProguard(outputJar: File, minecraftConfigs: List) { try { ProGuard(configuration).execute() } catch(ex: Exception) { - throw IllegalStateException("ProGuard failed for $outputJar", ex) + throw IllegalStateException("ProGuard failed for $jar", ex) } finally { inputJar.delete() } @@ -217,6 +195,7 @@ open class CompressJarTask : DefaultTask() { @Input var classShrinkingType = ClassShrinkingType.STRIP_ALL + get() = if (useProguard) ClassShrinkingType.STRIP_NONE else field @Input var jarShrinkingType = JarShrinkingType.LIBDEFLATE @@ -225,13 +204,12 @@ open class CompressJarTask : DefaultTask() { var jsonShrinkingType = JsonShrinkingType.NONE @get:Input - val useProguard get() = this.minecraftConfigs != null + val useProguard get() = !this.minecraftConfigs.isEmpty() - private var minecraftConfigs: List? = null + private var minecraftConfigs: List = emptyList() @get:OutputFile - val outputJar: File - get() = inputJar // compressed jar will replace the input jar + val outputJar get() = inputJar // compressed jar will replace the input jar @Option(option = "class-file-compression", description = "How to process class files") fun setClassShrinkingType(value: String) { @@ -242,7 +220,7 @@ open class CompressJarTask : DefaultTask() { fun setJarShrinkingType(value: String) { jarShrinkingType = value.uppercase().let { if(it.matches(Regex("7Z(?:IP)?"))) JarShrinkingType.SEVENZIP - else JarShrinkingType.valueOf(it.uppercase()) + else JarShrinkingType.valueOf(it) } } @@ -251,15 +229,15 @@ open class CompressJarTask : DefaultTask() { jsonShrinkingType = JsonShrinkingType.valueOf(value.uppercase()) } - fun useProguard(minecraftConfigs: List?) { + fun useProguard(minecraftConfigs: List) { this.minecraftConfigs = minecraftConfigs } @TaskAction fun compressJar() { + if (useProguard) + applyProguard(inputJar, minecraftConfigs, project.rootDir) squishJar(inputJar, classShrinkingType, jsonShrinkingType) deflate(outputJar, jarShrinkingType) - if (useProguard) - applyProguard(outputJar, minecraftConfigs!!) } } \ No newline at end of file diff --git a/gradle.properties b/gradle.properties index c9b57e7b..4534c968 100644 --- a/gradle.properties +++ b/gradle.properties @@ -90,7 +90,7 @@ vintage_forge_version = 14.23.5.2860 mixinbooter_version = 9.1 # Misc Dependencies -# https://central.sonatype.com/artifact/com.github.bsideup.jabel/jabel-javac-plugin +# https://central.sonatype.com/artifact/com.pkware.jabel/jabel-javac-plugin jabel_version = 1.0.1-1 # https://central.sonatype.com/artifact/blue.endless/jankson/overview jankson_version = 1.2.3 diff --git a/icon_padded.png b/icon_padded.png index 5da40b05941164ad82aee2df913e703b2d2daf43..94bf16169543f6b2a03a7de5bc9d25ba0994d6e5 100644 GIT binary patch delta 141 zcmV;80CNBBBc1_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large.png b/icon_padded_large.png index 1c458368083b970431e9dd6458df546200e8f6b8..249b149bcecdd72c32827dbf8fc3eed10eecaa45 100644 GIT binary patch literal 842 zcmeAS@N?(olHy`uVBq!ia0y~yU}^wi7G|KxzsFYufRtQ-Pl)TBIde|m{xf^+_BnGl zL`6mU`}=!&c{w{f+t}DxSXfwJQ)>rmd+zDt7*cWT&A~>XHim`;e^-jHWCAg9f*G;a z%lRZYnlyIUadb3k>aYeza4l2dT9mNuob{#JYwZE+)n~6+yXMWE^guQN1&0PE4j{?M z!XdDLfr*79fPs;TMWX>oiZ}pCE(M3Lf!(i8MSYRZ-H%UI0|P6>uz=$KjJsEy%jxKg zM>7!BSeS+v@*mV!Nt?UzM=TI#L$Mg90@Z!@pFS!T+ffO28dL?$YW)5{Hx93-(G>%| z64L$ZT<^tStiT|_B8wJsuNI5(UcC0dp?)H(RU$6s@8qFD3{-HzKB4p2R9WJ}_=5cc zps{%33})jC`3p>-IE3**L5VfO|2K$XPXJkVsIi#Up%dWG&hq0vpDYI`337be9+%MK z= literal 6753 zcmeHLdsGzX6`uuBf};405lxm=8&PL>W|@6Wb_E24H7@u7MXir{e2W9@!`%T^t+=A1 zQDYjkHBAv?(wekFeH~+tNfcj+If+2)i5`;%2(`ta6+BcCBiL_dVcAuV4Mk7?D9bm@ zH{ZSUyZ8R?{qF9}YqOIRLqo=dAP5p_Op2e2AOUXS2o8WN8xAhz;i(Fw8_h=JWF#0~ zKut+ML;`1Ss3P&12S@^uK)7BAk6~~w=m^IcNsxHn4(H(=^IdR0sY6Gwgi8XDP3E9*vwouKoD2)+BXeJXJbYe*6g2|FnMck*vbo4 zDCE855tNw3vR z+%yV*@vq;VT~qU;qh*|wm^|y~3A4m>{35T6Fgp*>*GI+8RxGgNj_D%o#wROQ$zLtT3%{}y&)1_?Yxq0X2q+N9U3YATQ3D zaCpnaq_BPO6e=el8v6c{m(NdsyJGmX_Mul4Z@wC_;DzmD2YxVp!_E7rAJ*pC%FbNd zxO+r0@||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sGKR271oix>x6yqv3@Se7in6=wbVY#A|!~ z6ZT)m_*1wMDtGbxtR;6E_wN6^s#O<#FKHC91I~7TDV9q&roHUV7yUD|Al{ z+&eXk2JYGG9K0ubN8(H07tDjZ}1-+KlrX4AGqwMk+ z@>I)<LviGEV3$U9+-S}l`t>xI| zs@6|is#?pA!GveL^qe2hUaGs{`AM=TbN5X;P1t#N?^UBQNO#>c& RExfHaCM3uIY5MYle*; } # dont rename config fields +-keep,allowoptimization class dev.nolij.zume.ZumeMixinPlugin # dont rename mixin plugin +-keep class dev.nolij.zume.mixin.** { *; } # dont touch mixins + +-keep,allowobfuscation,allowoptimization @*.*.fml.common.Mod class dev.nolij.zume.** { # Forge entrypoints + public (...); + @*.*.fml.common.Mod$EventHandler ; + @*.*.fml.common.eventhandler.SubscribeEvent ; +} +-keep,allowoptimization class dev.nolij.zume.** implements *.*.fml.client.IModGuiFactory # Legacy Forge config providers + +-keepclassmembers,allowoptimization class dev.nolij.zume.** { # screens + public void render(int,int,float); + public void tick(); + public void init(); +} +-keepclassmembers,allowoptimization class dev.nolij.zume.** extends net.minecraft.client.gui.screens.Screen { public *; } + +-keep,allowoptimization class io.github.prospector.modmenu.** { *; } # ugly classloader hack + +# Fabric entrypoints +-keep,allowoptimization class dev.nolij.zume.FabricZumeBootstrapper +-keep,allowoptimization class dev.nolij.zume.modern.integration.ZumeModMenuIntegration +-keep,allowoptimization class dev.nolij.zume.primitive.event.KeyBindingRegistrar { public *; } diff --git a/src/main/resources/META-INF/mods.toml b/src/main/resources/META-INF/mods.toml index 495ef8c3..9985b1a9 100644 --- a/src/main/resources/META-INF/mods.toml +++ b/src/main/resources/META-INF/mods.toml @@ -8,7 +8,7 @@ modId="zume" version="${mod_version}" displayName="${mod_name}" displayURL="${mod_url}" -logoFile="icon_large.png" +logoFile="icon.png" authors="${nolij}" description=""" ${mod_description} diff --git a/src/main/resources/mcmod.info b/src/main/resources/mcmod.info index f35cd8c3..b0f2e339 100644 --- a/src/main/resources/mcmod.info +++ b/src/main/resources/mcmod.info @@ -9,7 +9,7 @@ "updateUrl": "", "authorList": ["${nolij}"], "credits": "", - "logoFile": "icon_large.png", + "logoFile": "icon.png", "screenshots": [], "dependencies": [] } diff --git a/vintage/src/main/resources/mcmod.info b/vintage/src/main/resources/mcmod.info index 17251517..8586a830 100644 --- a/vintage/src/main/resources/mcmod.info +++ b/vintage/src/main/resources/mcmod.info @@ -9,7 +9,7 @@ "updateUrl": "", "authorList": ["${nolij}"], "credits": "", - "logoFile": "icon_large.png", + "logoFile": "icon.png", "screenshots": [], "dependencies": [] }