1 Commits
Author SHA1 Message Date
ProGuard Rollout 0296c7143b chore: minimal standalone ProGuard (baseline + proguard-mod.pro)
Build / build (push) Skipped
Build / publish (push) Skipped
Build / build (pull_request) Failing after 1m32s
Build / publish (pull_request) Skipped
Align with Stratum-default + per-mod overrides: do not ship a full duplicate
ruleset beyond proguard-baseline.pro; extras go in proguard-mod.pro only.
2026-11-08 14:17:58 +00:00
4 changed files with 57 additions and 74 deletions

No files matched your search

+1 -1
View File
@@ -3,5 +3,5 @@ plugins { id 'com.gtnewhorizons.gtnhconvention' }
version = providers.gradleProperty('modVersion').get()
// TDLM ProGuard baseline (optional: -PtdlmProguard)
// Standalone ProGuard (non-Stratum): baseline + optional proguard-mod.pro
apply from: 'proguard.gradle'
+3 -7
View File
@@ -1,11 +1,12 @@
# TDLM Forge ProGuard baseline — see docs/proguard-baseline.md
# Stratum Forge ProGuard baseline (1.7.10 / GTNH).
# Injected by stratum.init.gradle — do not pretend string encryption exists here.
-dontoptimize
-dontpreverify
-allowaccessmodification
-keepattributes Signature,InnerClasses,EnclosingMethod,*Annotation*,RuntimeVisibleAnnotations,RuntimeInvisibleAnnotations,AnnotationDefault,SourceFile,LineNumberTable
# Forge @Mod entry (1.7.10 FML + newer)
# Forge @Mod entry (FML 1.7.10 + newer)
-keep @cpw.mods.fml.common.Mod class * { *; }
-keep @net.minecraftforge.fml.common.Mod class * { *; }
-keepclassmembers class * {
@@ -67,8 +68,3 @@
-dontwarn groovy.**
-dontwarn javax.**
-dontwarn sun.**
# --- Auto-scanned keeps (@Mod / mixin / coremod) ---
-keep class com.pengu.thaumcraft.additions.core.TACore { *; }
-keep class com.pengu.thaumcraft.additions.preloader.ThaumicALoaderContainer { *; }
+3
View File
@@ -0,0 +1,3 @@
# Per-mod overrides (Mixin / @Mod FQN / coremod). Shared baseline is proguard-baseline.pro.
-keep class com.pengu.thaumcraft.additions.core.TACore { *; }
-keep class com.pengu.thaumcraft.additions.preloader.ThaumicALoaderContainer { *; }
+50 -66
View File
@@ -1,6 +1,6 @@
// ProGuard wiring for Forge mods (FG1 / GTNH / plain Gradle).
// Applied via: apply from: 'proguard.gradle'
// Mapping lands in build/proguard/ — do not commit unless the repo already does.
// Minimal standalone ProGuard wiring for Forge mods that are NOT on Stratum.
// Stratum layers should NOT use this file — enable stratum.proguard instead.
// Layout: proguard-baseline.pro (shared rules) + optional proguard-mod.pro (overrides only).
configurations {
proguardPath
@@ -15,97 +15,81 @@ dependencies {
}
def pgDir = file("${buildDir}/proguard")
def pgRules = rootProject.file('proguard-rules.pro')
if (!pgRules.exists()) {
pgRules = file('proguard-rules.pro')
}
def baseline = rootProject.file('proguard-baseline.pro')
if (!baseline.exists()) baseline = file('proguard-baseline.pro')
def modOverride = rootProject.file('proguard-mod.pro')
if (!modOverride.exists()) modOverride = file('proguard-mod.pro')
task proguardJar(type: JavaExec) {
group = 'build'
description = 'Shrink/obfuscate the jar with ProGuard (Forge-safe baseline)'
// Prefer after jar; FG reobf consumers should depend on this output.
description = 'Shrink/obfuscate jar (standalone baseline + optional proguard-mod.pro)'
dependsOn tasks.matching { it.name == 'jar' }
classpath = configurations.proguardPath
mainClass = 'proguard.ProGuard'
if (hasProperty('mainClass')) {
try { mainClass.set('proguard.ProGuard') } catch (Throwable t) { main = 'proguard.ProGuard' }
} else {
main = 'proguard.ProGuard'
}
outputs.dir pgDir
doFirst {
if (!baseline.exists()) {
throw new GradleException('Missing proguard-baseline.pro (standalone non-Stratum mods)')
}
pgDir.mkdirs()
def jarTask = tasks.findByName('jar')
if (jarTask == null) {
throw new GradleException('proguardJar requires a jar task')
}
def inJar = jarTask.archivePath
if (!inJar.exists()) {
throw new GradleException("Input jar missing: ${inJar}")
}
if (jarTask == null) throw new GradleException('proguardJar requires a jar task')
def inJar = jarTask.hasProperty('archiveFile') ? jarTask.archiveFile.get().asFile : jarTask.archivePath
if (!inJar.exists()) throw new GradleException("Input jar missing: ${inJar}")
def outJar = new File(pgDir, inJar.name.replace('.jar', '-proguard.jar'))
def mapping = new File(pgDir, 'mapping.txt')
def seeds = new File(pgDir, 'seeds.txt')
def usage = new File(pgDir, 'usage.txt')
// JDK library jars: prefer Java 8 rt.jar when present (1.7.10 builds)
def javaHome = System.getProperty('java.home')
def libJars = []
def rt = file("${javaHome}/lib/rt.jar")
def rtJre = file("${javaHome}/../lib/rt.jar")
if (rt.exists()) libJars << rt
else if (rtJre.exists()) libJars << rtJre
else {
// JDK 9+: use jmods as library (best-effort; prefer building with JDK8 for 1.7.10)
def jmod = file("${javaHome}/jmods/java.base.jmod")
if (jmod.exists()) libJars << jmod
}
def argsList = [
def conf = new File(pgDir, 'proguard-generated.conf')
def lines = [
"-injars '${inJar.absolutePath}'",
"-outjars '${outJar.absolutePath}'",
"-include '${pgRules.absolutePath}'",
"-printmapping '${mapping.absolutePath}'",
"-printseeds '${seeds.absolutePath}'",
"-printusage '${usage.absolutePath}'",
"-include '${baseline.absolutePath}'",
"-printmapping '${new File(pgDir, 'mapping.txt').absolutePath}'",
"-printseeds '${new File(pgDir, 'seeds.txt').absolutePath}'",
"-printusage '${new File(pgDir, 'usage.txt').absolutePath}'",
]
libJars.each { lj ->
if (lj.name.endsWith('.jmod')) {
argsList << "-libraryjars '${lj.absolutePath}'(!**.jar;!module-info.class)"
} else {
argsList << "-libraryjars '${lj.absolutePath}'"
}
if (modOverride.exists()) {
lines.add("-include '${modOverride.absolutePath}'")
}
def javaHome = System.getProperty('java.home')
def rt = file("${javaHome}/lib/rt.jar")
def rtJre = file("${javaHome}/../lib/rt.jar")
if (rt.exists()) lines.add("-libraryjars '${rt.absolutePath}'")
else if (rtJre.exists()) lines.add("-libraryjars '${rtJre.absolutePath}'")
else {
def jmod = file("${javaHome}/jmods/java.base.jmod")
if (jmod.exists()) lines.add("-libraryjars '${jmod.absolutePath}'(!**.jar;!module-info.class)")
}
// Optional: compile classpath as library jars (helps -dontwarn less)
try {
configurations.compileClasspath.files.findAll { it.name.endsWith('.jar') }.each { f ->
// Skip the project jar itself
if (f.absolutePath != inJar.absolutePath) {
argsList << "-libraryjars '${f.absolutePath}'"
}
if (f.absolutePath != inJar.absolutePath) lines.add("-libraryjars '${f.absolutePath}'")
}
} catch (Throwable ignored) {
try {
configurations.compile.files.findAll { it.name.endsWith('.jar') }.each { f ->
if (f.absolutePath != inJar.absolutePath) {
argsList << "-libraryjars '${f.absolutePath}'"
}
if (f.absolutePath != inJar.absolutePath) lines.add("-libraryjars '${f.absolutePath}'")
}
} catch (Throwable ignored2) { /* FG1 may use different configs */ }
} catch (Throwable ignored2) { /* FG1 */ }
}
def conf = new File(pgDir, 'proguard-generated.conf')
conf.text = argsList.join('\n') + '\n'
conf.text = lines.join('\n') + '\n'
args '-include', conf.absolutePath
ext.pgOut = outJar
ext.pgIn = inJar
}
doLast {
def outJar = ext.pgOut as File
def inJar = ext.pgIn as File
if (!outJar.exists()) throw new GradleException("proguardJar produced no output: ${outJar}")
java.nio.file.Files.copy(outJar.toPath(), inJar.toPath(), java.nio.file.StandardCopyOption.REPLACE_EXISTING)
}
}
// Hook: if reobfJar exists, run proguard after jar and before reobf when safe.
// Default: expose proguardJar; repos may `assemble.dependsOn proguardJar`.
afterEvaluate {
def assemble = tasks.findByName('assemble')
if (assemble != null && tasks.findByName('proguardJar') != null) {
// Do not force into default assemble for FG1 (reobf ordering differs);
// enable with -PtdlmProguard or property tdlm.proguard=true
if (project.hasProperty('tdlmProguard') || project.findProperty('tdlm.proguard') == 'true') {
assemble.dependsOn proguardJar
}
if (assemble != null && (project.hasProperty('tdlmProguard') || project.findProperty('tdlm.proguard') == 'true')) {
assemble.dependsOn proguardJar
}
}