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

Add proguardInJarsFilter key #150

Closed yuchangyuan closed 11 years ago

yuchangyuan commented 11 years ago

This key is similar to makeInJarFilter key in xsbt-proguard-plugin.

appamatto commented 11 years ago

Hmm, maybe a "cleaner" way is to provide a setting that will exclude some files from all jars:

proguardExclude := Seq("!**/gwt.xml", "!**/*.png")

And then repeat these exclusions across all JARs.

I think the partial function exclusions are going to be too complicated to use. At that point, the user should probably exclude the files from his JAR manually and republish.

yuchangyuan commented 11 years ago

My original usage is to use this option to replace some classes with my own version:

    proguardInJarsFilter in Android <<= (proguardInJarsFilter in Android) {
      (proguardInJarsFilter) => {
        (file) => {
          val s = file.getName
          if (s.matches("sesame-sail-api-.*.jar")) {
            "\"" + file + "\"(!org/openrdf/sail/helpers/DirectoryLockManager*)"
          }
          else if (s.matches("sesame-util-.*.jar")) {
            "\"" + file + "\"(!info/aduna/lang/service/ServiceRegistry*)"
          }
          else if (s.matches("xml-apis-.*.jar")) {
            "\"" + file + "\"(!**.class)"
          }
          else if (s.matches("xercesImpl-.*.jar")) {
            "\"" + file + "\"(!javax/**.class)"
          }
          else {
            proguardInJarsFilter(file)
          }
        }
      }
    },

Since #154 fullfill my needs(and do more), I will just close this pull.

yuchangyuan commented 11 years ago

Sorry, I just find that #154 is not merged but simply closed, so I reopen my issue. Please consdier either merge #154 or this pull, thank you.

If I am wrong(actually merged), please close this pull.

appamatto commented 11 years ago

I rewrote the patch to be a little more user-friendly. Do you think it will fix your use case? The setting takes a file and returns a sequence of exclusions. This is the default:

proguardInJarsFilter := { jar: File =>
  Seq("!META-INF/MANIFEST.MF", "!library.properties")
}

This is transformed into the necessary foo.jar(!META-INF/MANIFEST.MF,...) format.

yuchangyuan commented 11 years ago

I think it will fix for my use case, thank you very much.