Note that there are some explanatory texts on larger screens.

plurals
  1. POHow do I exclude/include specific packages using xsbt-proguard-plugin?
    primarykey
    data
    text
    <p>I'm using <a href="https://github.com/siasia/xsbt-proguard-plugin" rel="nofollow noreferrer">xsbt-proguard-plugin</a>, which is an SBT plugin for working with Proguard.</p> <p>I'm trying to come up with a Proguard configuration for a <a href="https://github.com/snowplow/snowplow-log-deserializers" rel="nofollow noreferrer">Hive Deserializer</a> I've written, which has the following dependencies:</p> <pre><code>// project/Dependencies.scala val hadoop = "org.apache.hadoop" % "hadoop-core" % V.hadoop val hive = "org.apache.hive" % "hive-common" % V.hive val serde = "org.apache.hive" % "hive-serde" % V.hive val httpClient = "org.apache.httpcomponents" % "httpclient" % V.http val logging = "commons-logging" % "commons-logging" % V.logging val specs2 = "org.specs2" %% "specs2" % V.specs2 % "test" </code></pre> <p>Plus an unmanaged dependency:</p> <pre><code>// lib/UserAgentUtils-1.6.jar </code></pre> <p>Because most of these are either for local unit testing or are available within a Hadoop/Hive environment anyway, I want my minified jarfile to only include:</p> <ul> <li>The Java classes SnowPlowEventDeserializer.class and SnowPlowEventStruct.class</li> <li><code>org.apache.httpcomponents.httpclient</code></li> <li><code>commons-logging</code></li> <li><code>lib/UserAgentUtils-1.6.jar</code></li> </ul> <p>But I'm really struggling to get the syntax right. Should I start from a whitelist of classes I want to keep, or explicitly filter out the Hadoop/Hive/Serde/Specs2 libraries? I'm aware of <a href="https://stackoverflow.com/questions/4830474/how-to-keep-exclude-a-particular-package-path-when-using-proguard">this SO question</a> but it doesn't seem to apply here.</p> <p>If I initially try the whitelist approach:</p> <pre><code>// Should be equivalent to sbt&gt; package import ProguardPlugin._ lazy val proguard = proguardSettings ++ Seq( proguardLibraryJars := Nil, proguardOptions := Seq( "-keepattributes *Annotation*,EnclosingMethod", "-dontskipnonpubliclibraryclassmembers", "-dontoptimize", "-dontshrink", "-keep class com.snowplowanalytics.snowplow.hadoop.hive.SnowPlowEventDeserializer", "-keep class com.snowplowanalytics.snowplow.hadoop.hive.SnowPlowEventStruct" ) ) </code></pre> <p>Then I get a Hadoop processing error, so clearly Proguard is still trying to bundle Hadoop:</p> <pre><code>proguard: java.lang.IllegalArgumentException: Can't find common super class of [[Lorg/apache/hadoop/fs/FileStatus;] and [[Lorg/apache/hadoop/fs/s3/Block;] </code></pre> <p>Meanwhile if I try <a href="http://proguard.sourceforge.net/index.html#manual/usage.html" rel="nofollow noreferrer">Proguard's filtering syntax</a> to build up the blacklist of libraries I don't want to include:</p> <pre><code>import ProguardPlugin._ lazy val proguard = proguardSettings ++ Seq( proguardLibraryJars := Nil, proguardOptions := Seq( "-keepattributes *Annotation*,EnclosingMethod", "-dontskipnonpubliclibraryclassmembers", "-dontoptimize", "-dontshrink", "-injars !*hadoop*.jar" ) ) </code></pre> <p>Then this doesn't seem to work either:</p> <pre><code>proguard: java.io.IOException: Can't read [/home/dev/snowplow-log-deserializers/!*hadoop*.jar] (No such file or directory) </code></pre> <p>Any help greatly appreciated!</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload