Closed KenobySky closed 5 years ago
Hello,
I am facing the same problem: jpackage with obfuscated jar(proguard).
I have tried the link above, but I can't make it work.
Regards,
Pai
I'm not sure if this is the right/best way but works for my project. I have included only the relevant parts that I pulled out of my build script (kotlin dsl)
/**
* Obfuscate with ProGuard
*/
tasks.register<ProGuardTask>("obfuscateJar") {
dependsOn("jar")
//Any initial setup ...
val archiveName: String = tasks.getByName<Jar>("jar").archiveFileName.get()
injars("${project.buildDir.absolutePath}/libs/$archiveName")
outjars("${project.buildDir.absolutePath}/obfLibs/$archiveName")
//Make other proguard configurations ...
doLast {
delete("${project.buildDir.absolutePath}/libs/$archiveName")
copy {
from("${project.buildDir.absolutePath}/obfLibs/$archiveName")
into("${project.buildDir.absolutePath}/libs/")
}
}
}
/**
* Hook for obfuscating. Configures installDist to
* depend on obfuscate.
*/
tasks.installDist {
dependsOn("obfuscateJar")
}
The key parts in the obfuscate task, are to output the obfuscated jar to some temp directory. In my case to a directory called 'obfLibs'. Then after the obfuscation is done, delete the un-obfuscated jar, and copy the obfuscated jar to where the original one was.
I then hooked into the obfuscate task by setting the installDist
task, to dependOn the obfuscate task. The runtime
task in turn then depends on installDist
, so in the end runtime
-> installDir
-> obfucateJar
- > jar
, so now obfuscate is part of the build flow.
Hopefully, that makes sends, helps you get started.
Thank you so much, I get it.
my example works now:
tasks.installDist { dependsOn("proguard") dependsOn("copyJar") proguard.finalizedBy copyJar }
Regards,
Pai
Hi! Sorry for bothering you again DjVicking. But I got stuck and sincerely, couldnt find someone to help me with this.
My current gradle version is: gradle-5.6.2-all
Problem description
How do I use proguard so the code gets obfuscated and optimized before jPackage do its job? I mean, I want my code thats inside the .msi gets obfuscated.
Ive found a tutorial (Tutorial) for an older gradle version however im not sure how to mix this with the current plugins. I've tried the code below but im not sure how to merge it with jPackage task.