I've managed to obfuscate my Scala code but I can't figure out how to run obfuscation against a jar file that is built by sbt assembly
step. Or at least how to build a fat jar during the proguard
step. I found that there is a injar
argument for proguard but I have no clue how to apply it to build.sbt
. Can someone please point me to how I can do this.
UPD Actually the JAR that is built by Proguard contains only obfuscated classes and not a single class from those that are ignored by Proguard.
To run a Proguard obfuscation against a jar file that was built by assembly
task previously you should override inputs
setting in build.sbt:
proguardInputs in Proguard := Seq((assemblyOutputPath in assembly).value)
This would specify your fat jar as a single input for Proguard. Also you probably want to modify the input libraries that are used for obfuscation. Here is an example of how to exclude all the libraries:
proguardLibraries in Proguard := Seq()
Finally disable input filter since you have only one source of classes:
proguardInputFilter in Proguard := { file => None }
The setting above is required because Proguard will exclude META-INF/MANIFEST.MF
file by default. Also merge step is no longer required since assembly
task already performed this step:
proguardMerge in Proguard := false
And finally add assembly
dependency to your Proguard task:
(ProguardKeys.proguard in Proguard) <<= (ProguardKeys.proguard in Proguard).dependsOn(assembly)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With