Hi. I have a spring boot server app that I’m trying to obfuscate
Here’s my kotlin.dsl (build.gradle.kts) task:
tasks.register<proguard.gradle.ProGuardTask>("proguard-fat-jar") {
dependsOn("extractJar")
configuration("proguard-rules.pro")
injars(tasks.named("bootJar"))
outjars("build/libs/proguard-fat.jar")
libraryjars(System.getProperty("java.home") + "/jmods")
libraryjars(configurations.compileClasspath.get())
}
Everything goes well, until I open the .jar, and in BOOT-INF/classes/ I should see my project package (of my server) and it’s not there… It has the META-INF and files from resources
though
I also tried just doing the plain jar with injars(tasks.named("jar"))
and it works, using the same proguard-rules.pro file…
I tried following the spring boot example, but it was in gradle.build original syntax, not in kotlin dsl (build.gradle.kts), even then it should work… any help? tks
I made sure my proguard-rules had tons of variations of -keeps
proguard-rules.pro (3.6 KB)
Here is my conversion of the spring example to kotlin dsl:
tasks.register<Copy>("extractJar") {
dependsOn("assemble")
val zipFile = file("${buildDir}/libs/${project.name}-${project.version}.jar")
val outputDir = file("${buildDir}/extracted/")
copy {
from( zipTree(zipFile) )
into(outputDir)
}
}
tasks.register<Delete>("deleteClasses") {
delete("${buildDir}/extracted/BOOT-INF/classes/")
}
tasks.register<Copy>("copyObfuscatedClasses") {
dependsOn("deleteClasses")
copy {
from( zipTree("${buildDir}/obfuscatedClasses.jar") )
into("${buildDir}/extracted/BOOT-INF/classes/")
}
}
tasks.register<Delete>("deleteObfuscated") {
delete("build/obfuscatedClasses.jar")
}
tasks.register<Zip>("repackage") {
dependsOn("deleteClasses")
dependsOn("copyObfuscatedClasses")
dependsOn("deleteObfuscated")
from("${buildDir}/extracted")
entryCompression = ZipEntryCompression.STORED
archiveFileName.set("demo-${archiveVersion.get()}-obfuscated.jar")
destinationDirectory.set(file("${buildDir}/libs"))
}
tasks.register<proguard.gradle.ProGuardTask>("proguard-fat-jar") {
dependsOn("extractJar")
configuration("proguard-rules.pro")
//configuration("${rootProject.projectDir}/proguard-rules.pro")
injars(tasks.named("bootJar"))
//injars("${project.buildDir}/libs/${project.name}-${project.version}.jar")
outjars("build/libs/proguard-fat.jar")
adaptresourcefilecontents()
//target("11")
//keepattributes("Exceptions,InnerClasses,Signature,Deprecated,SourceFile,LineNumberTable,*Annotation*,EnclosingMethod")
libraryjars(System.getProperty("java.home") + "/jmods")
libraryjars(configurations.compileClasspath.get())
finalizedBy.getDependencies(tasks.getByName("repackage"))
}
It didn’t work. Am I missing something?
And thanks to all these attempts now my gradle is broken and says immediately upon any gradle action: Could not initialize class jdk.internal.math.FormattedFloatingDecimal