From d47de62bfa0ad1d47db47fccbc5e46da2ce2aa19 Mon Sep 17 00:00:00 2001 From: Username404-59 Date: Sat, 17 Apr 2021 14:46:37 +0200 Subject: [PATCH] Fix the shrinkJar task --- build.gradle.kts | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index ccbb78c..3538cec 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,5 +1,6 @@ import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar import com.modrinth.minotaur.request.VersionType +import org.gradle.internal.jvm.Jvm buildscript { dependencies { classpath("com.guardsquare:proguard-gradle:7.1.0-beta2") { @@ -40,13 +41,23 @@ subprojects { keep("class fr.username404.snowygui.fabric.** { * ; }") keep("class fr.username404.snowygui.forge.** { * ; }") keepclassmembers("class fr.username404.snowygui.** { public protected ; }") - // TODO Fix kotlin keepattributes(); keepdirectories(); keeppackagenames(); keepparameternames() obfuscationdictionary("$dictionariesDir/dictionary.txt") classobfuscationdictionary("$dictionariesDir/classdictionary.txt") adaptclassstrings() "fr.username404.**".also { dontwarn(it); dontnote(it) } - dontwarn("java.**") // Needed for the current version of proguard + + // The following lines are needed at least for the current version of proguard + dontwarn("java.**") + onlyIf { + JavaVersion.current().isJava8.also { + if (it) { + libraryjars("${Jvm.current().javaHome}/lib/rt.jar") + libraryjars("${Jvm.current().javaHome}/lib/jce.jar") + } else println("The shrinkJar task is disabled because Java 9 or higher does not work with our current proguard configuration.") + } + } + // Note: dontpreverify() should NOT be used, it will cause errors at runtime useuniqueclassmembernames() optimizations("method/inlining/*, code/allocation/variable, class/merging/vertical, code/removal/advanced, code/simplification/branch, code/merging") @@ -81,10 +92,12 @@ allprojects { } tasks { withType(ShadowJar::class) { - minimize { - exclude(project(":common")) - } relocate("kotlin", "${rootProject.group}.kotlin") + relocate("com.typesafe.config", "${rootProject.group}.typesafe.config") + relocate("io.github.config4k", "${rootProject.group}.config4k") + exclude("**/*.kotlin_metadata") + exclude("**/*.kotlin_builtins") + exclude("META-INF/maven/**/*") archiveClassifier.set("shadow") } withType(Jar::class) {