-
Notifications
You must be signed in to change notification settings - Fork 441
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
proguard support #518
Comments
Haven't used it yet, but if you have a working example, I am interested. |
Any progress @joprice ? |
@muuki88 I was able to create a Raspbian .deb file for a scala service with sbt-native-packager but it's huge. Is there any way to get proguard to process the jar before it is packaged? Would it require a separate Proguard AutoPlugin implementation inside sbt-native-packager? |
To work with native-packager proguard needs to support multiple jars as input and stripping out the class files in each of them. IMHO the best way would be to use native packager together with sbt-assembly and use proguard on the assembly jar. |
@muuki88 Thanks---I am doing this in a multiple-project setup, and my lazy val mysubproject = project.in(file("mysubproject")).
enablePlugins(JavaAppPackaging).
settings(proguardSettings: _*).
settings(assemblySettings: _*).
settings(
name := "mysubproject",
version := "0.0.1",
serverLoading in Debian := ServerLoader.SystemV,
debianPackageDependencies in Debian := Seq("mosquitto"),
jarName in assembly := "mysubproject.jar",
mappings in Universal := {
val universalMappings = (mappings in Universal).value
val fatJar = (assembly in Compile).value
val filtered = universalMappings filter {
case (file, name) => ! name.endsWith(".jar")
}
filtered :+ (fatJar -> ("lib/" + fatJar.getName))
},
ProguardKeys.options in Proguard ++= Seq("-dontnote", "-dontwarn", "-ignorewarnings"),
ProguardKeys.options in Proguard += ProguardOptions.keepMain("com.example.Main"),
ProguardKeys.proguardVersion in Proguard := "5.2",
scriptClasspath := Seq( (jarName in assembly).value ),
// ... etc.
)) Running |
The code above is almost correctly. You are adding the Something like // before: val fatJar = (assembly in Compile).value
val proguardJar = (proguard in proguard).value |
@muuki88 Thanks! Based on your suggestions I got it working with something similar to this: lazy val mysubproject = project.in(file("mysubproject")).
enablePlugins(JavaAppPackaging).
settings(proguardSettings: _*).
settings(
name := "mysubproject",
version := "0.0.1",
serverLoading in Debian := ServerLoader.SystemV,
debianPackageDependencies in Debian := Seq("mosquitto"),
ProguardKeys.options in Proguard ++= Seq("-dontnote", "-dontwarn", "-ignorewarnings"),
ProguardKeys.options in Proguard += ProguardOptions.keepMain("com.example.Main"),
ProguardKeys.proguardVersion in Proguard := "5.2",
mappings in Universal := (mappings in Universal).value.
filter {
case (file, name) => ! name.endsWith(".jar")
},
mappings in Universal ++= (ProguardKeys.proguard in Proguard).value.map(jar => jar -> ("lib/" +jar.getName)),
scriptClasspath := (ProguardKeys.proguard in Proguard).value.map(x => x.getName),
// etc.
)
Then... > mysubproject/universal:package-zip-tarball
> mysubproject/debian:package-zip-tarfile
The proguard command-line parameters need some adjustment, but that's the basic idea. Very cool! |
Nice! If you like you could open a small pull request enhancing the docs with your example in the same section where the assembly example is. |
Ok, there we go. The actual proguard config for a simple raspberry pi project is massive, but I'll save that for a blog post. :) |
I didn't have time to follow up on this. Thanks @mikebridge! |
Any tips on integration with sbt-proguard?
The text was updated successfully, but these errors were encountered: