scala - How to exclude transitive dependency in Sbt ( in context of assembly plugin )? -
i have 2 sbt projects, my-commons , my-service.
my-commons
with dependencies
librarydependencies ++= seq( "nz.ac.waikato.cms.weka" % "attributeselectionsearchmethods" % "1.0.7", "de.bwaldvogel" % "liblinear" % "1.95" "io.dropwizard.metrics" % "metrics-graphite" % "3.1.2", "com.github.nscala-time" %% "nscala-time" % "2.2.0", "org.apache.hive" % "hive-jdbc" % "1.1.0-cdh5.4.5", "org.apache.hadoop" % "hadoop-common" % "2.6.0-cdh5.4.5", "org.apache.hadoop" % "hadoop-hdfs" % "2.6.0-cdh5.4.5" )
my-service:
with dependencies
librarydependencies ++= { seq( "ch.qos.logback" % "logback-classic" % "1.0.13", "io.spray" %% "spray-httpx" % "1.3.3", "io.spray" %% "spray-json" % "1.3.2", "io.spray" %% "spray-can" % "1.3.3", "io.spray" %% "spray-routing" % "1.3.3", "io.spray" %% "spray-testkit" % "1.3.3" % "test", "com.typesafe.akka" %% "akka-actor" % "2.3.9", "com.typesafe.akka" %% "akka-testkit" % "2.3.9" % "test", "org.specs2" %% "specs2-core" % "2.3.11" % "test", "org.json4s" %% "json4s-native" % "3.2.11", "org.json4s" %% "json4s-ext" % "3.2.11", "org.mockito" % "mockito-all" % "1.8.4" % "test", "com.mycommon.projects" % "my-commons" % "1.0.+" )
i'm using assembly sbt plugin
addsbtplugin("com.eed3si9n" % "sbt-assembly" % "0.11.2")
i'm getting error on sbt assembly:
at java.lang.thread.run(thread.java:745) [error] (*:assembly) deduplicate: different file contents found in following: [error] /home/me/.ivy2/cache/org.slf4j/slf4j-api/jars/slf4j-api-1.7.7.jar:meta-inf/maven/org.slf4j/slf4j-api/pom.properties [error] /home/me/.ivy2/cache/com.twitter/parquet-hadoop-bundle/jars/parquet-hadoop-bundle-1.5.0-cdh5.4.5.jar:meta-inf/maven/org.slf4j/slf4j-api/pom.properties
i've tried exclude libs build no success.
librarydependencies ~= { _ map { case m if m.organization.startswith("org.apache") || m.organization.startswith("com.twitter") || m.name.contains("parquet") => m.exclude("org.slf4j","slf4j-api"). exclude("org.slf4j","slf4j-log4j12") case m => m }}
probably i'm doing wrong... how can resolve dependency hell?
in case, files exist different content , can't merged sbt assembly plugin.
two approaches possible
approach 1:
use merge filter of assembly plugin specify, files keep, e.g.
val sharedmergestrategy: (string => mergestrategy) => string => mergestrategy = (old: (string) => mergestrategy) => { case x if x.startswith("meta-inf/eclipsef.rsa") => mergestrategy.last case x if x.startswith("meta-inf/mailcap") => mergestrategy.last case x if x.endswith("plugin.properties") => mergestrategy.last case x => old(x) }
approach 2:
see http://www.scala-sbt.org/0.13/docs/library-management.html#exclude+transitive+dependencies on how exclude transitive dependencies.
Comments
Post a Comment