Fix the shrinkJar task
This commit is contained in:
		
							parent
							
								
									dac1294ee3
								
							
						
					
					
						commit
						d47de62bfa
					
				@ -1,5 +1,6 @@
 | 
				
			|||||||
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
 | 
					import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
 | 
				
			||||||
import com.modrinth.minotaur.request.VersionType
 | 
					import com.modrinth.minotaur.request.VersionType
 | 
				
			||||||
 | 
					import org.gradle.internal.jvm.Jvm
 | 
				
			||||||
buildscript {
 | 
					buildscript {
 | 
				
			||||||
    dependencies {
 | 
					    dependencies {
 | 
				
			||||||
        classpath("com.guardsquare:proguard-gradle:7.1.0-beta2") {
 | 
					        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.fabric.** { * ; }")
 | 
				
			||||||
            keep("class fr.username404.snowygui.forge.** { * ; }")
 | 
					            keep("class fr.username404.snowygui.forge.** { * ; }")
 | 
				
			||||||
            keepclassmembers("class fr.username404.snowygui.** { public protected <methods>; }")
 | 
					            keepclassmembers("class fr.username404.snowygui.** { public protected <methods>; }")
 | 
				
			||||||
            // TODO Fix kotlin
 | 
					 | 
				
			||||||
            keepattributes(); keepdirectories(); keeppackagenames(); keepparameternames()
 | 
					            keepattributes(); keepdirectories(); keeppackagenames(); keepparameternames()
 | 
				
			||||||
            obfuscationdictionary("$dictionariesDir/dictionary.txt")
 | 
					            obfuscationdictionary("$dictionariesDir/dictionary.txt")
 | 
				
			||||||
            classobfuscationdictionary("$dictionariesDir/classdictionary.txt")
 | 
					            classobfuscationdictionary("$dictionariesDir/classdictionary.txt")
 | 
				
			||||||
            adaptclassstrings()
 | 
					            adaptclassstrings()
 | 
				
			||||||
            "fr.username404.**".also { dontwarn(it); dontnote(it) }
 | 
					            "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
 | 
					            // Note: dontpreverify() should NOT be used, it will cause errors at runtime
 | 
				
			||||||
            useuniqueclassmembernames()
 | 
					            useuniqueclassmembernames()
 | 
				
			||||||
            optimizations("method/inlining/*, code/allocation/variable, class/merging/vertical, code/removal/advanced, code/simplification/branch, code/merging")
 | 
					            optimizations("method/inlining/*, code/allocation/variable, class/merging/vertical, code/removal/advanced, code/simplification/branch, code/merging")
 | 
				
			||||||
@ -81,10 +92,12 @@ allprojects {
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
    tasks {
 | 
					    tasks {
 | 
				
			||||||
        withType(ShadowJar::class) {
 | 
					        withType(ShadowJar::class) {
 | 
				
			||||||
            minimize {
 | 
					 | 
				
			||||||
                exclude(project(":common"))
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
            relocate("kotlin", "${rootProject.group}.kotlin")
 | 
					            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")
 | 
					            archiveClassifier.set("shadow")
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        withType(Jar::class) {
 | 
					        withType(Jar::class) {
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user