jberkel / android-plugin

An sbt plugin for Android development in Scala
https://groups.google.com/forum/#!forum/scala-on-android
Other
476 stars 113 forks source link

How to specify alternate proguard configuration? #24

Closed hrj closed 13 years ago

hrj commented 13 years ago

I am not well versed with SBT plugins, or even with SBT for that matter.

How can I instruct the proguard task to use an external configuration file?

From a cursory glance it looks like the proguard task has all the command line parameters specified in the task definition itself.

jberkel commented 13 years ago

you cannot specify a config file, but inline the config by overriding proguardOption in your project.

it guess the ability to specify a file would be a nice feature to have.

CitizenB commented 13 years ago

Here's an example which I used to get rid of a boatload of proguard spew/helpful messages. In the simplest case, just jam this code or similar in your sbt project definition class.

val toKeep = List(
  "scala.Function1",
  "scala.Function2",
  "scala.Tuple2",
  "org.xml.sax.EntityResolver",
  ...more class names here...
)

val keepOptions = toKeep.map { "-keep public class " + _ }

val dontNote = List(
  // Proguard message: "Note: com.admob.android.ads.analytics.InstallReceiver: can't find dynamically referenced class com.google.android.apps.analytics.AnalyticsReceiver"
  "com.admob.android.ads.analytics.InstallReceiver",
  // Proguard message:  "Note: scala.Enumeration accesses a field 'MODULE$' dynamically"
  "scala.Enumeration"
)
val dontNoteOptions = dontNote.map { "-dontnote " + _ }

override def proguardOption = (super.proguardOption ++ keepOptions ++ dontNoteOptions) mkString " "

I was kicking around the idea of writing some wrappers for proguard config along these lines.

jberkel commented 13 years ago

see GH-57