0
votes

I'm trying to scope an unmanaged dependencies libararies from my main project. Here is the scenario

I have an unamanaged dependency in my lib folder called coinprism-api-assembly-1.2.jar which has the following Build.scala file:

  1 import sbt._
  2 import Keys._
  3 object CoinPrismBuild extends Build {
  4 
  5   val appName = "coinprism-api"
  6   val appV = "1.2"
  7   val scalaV = "2.11.2"
  8   val akkaV = "2.3.6"
  9   val sprayV = "1.3.2"
 10 
 11   val appDependencies = Seq(
 12     "com.typesafe.akka"   %%  "akka-actor"    % akkaV  withSources() withJavadoc(),
 13     "com.typesafe.akka"   %%  "akka-testkit"  % akkaV   % "test"  withSources() withJavadoc(),
 14     "io.spray"            %%  "spray-client"     % sprayV  withSources() withJavadoc(),
 15     "io.spray" %% "spray-can" % sprayV  withSources() withJavadoc(),
 16     "io.spray" %% "spray-routing" % sprayV  withSources() withJavadoc(),
 17     "io.spray" %%  "spray-json" % "1.3.1" withSources() withJavadoc(),
 18     "io.spray" %% "spray-testkit" % sprayV % "test" withSources() withJavadoc(),
 19     "org.scalatest" %% "scalatest" % "2.2.4" % "test" withSources() withJavadoc(),
 20     "joda-time" % "joda-time" % "2.7"
 21   )
 22 
 23 
 24   lazy val root = Project(appName, base=file(".")).settings(
 25     scalaVersion := scalaV,
 26     version := appV,
 27     libraryDependencies ++= appDependencies
 28   )
 29 
 30 }

The project I am trying to assemble has the following build.sbt file:

import AssemblyKeys._    

name := "suredbits-core" 

version := "2.13.0" 

scalaVersion := "2.11.4" 

resolvers += Resolver.mavenLocal

organization := "com.suredbits.core"

libraryDependencies ++= {  
    val sprayV = "1.3.2"
    val akkaV = "2.3.8" 
    Seq(
    "org.scalatest" % "scalatest_2.11" % "2.2.0",
    "io.spray"            %%  "spray-can"     % sprayV % "provided"  withSources() withJavadoc(),
    "io.spray"            %%  "spray-routing" % sprayV % "provided"  withSources() withJavadoc(),
    "io.spray"            %%  "spray-testkit" % sprayV  % "test"  withSources() withJavadoc(),
    "com.typesafe.akka"   %%  "akka-actor"    % akkaV % "provided" withSources() withJavadoc(),
    "com.typesafe.akka"   %%  "akka-testkit"  % akkaV   % "test" withSources() withJavadoc(),
    "org.specs2"          %%  "specs2-core"   % "2.4.7-scalaz-7.0.6" % "test" withSources() withJavadoc(),
    "org.scalactic"             %%  "scalactic" %   "2.2.1" % "test" withSources() withJavadoc(),
    "io.spray" %%  "spray-json" % "1.3.0" withSources() withJavadoc(),
    "info.blockchain" % "api" % "1.0.1", 
    "com.github.nscala-time" %% "nscala-time" % "1.6.0" withSources() withJavadoc() ,
    "com.typesafe.slick" %% "slick" % "2.1.0" withSources() withJavadoc(),
    "com.typesafe.slick" %% "slick-testkit" % "2.1.0" % "test" withSources() withJavadoc(),
    "com.novocode" % "junit-interface" % "0.10" % "test" withSources() withJavadoc(),
    "postgresql" % "postgresql" % "9.1-901.jdbc4" % "test" withSources() withJavadoc(),
    "org.postgresql" % "postgresql" % "9.2-1003-jdbc4" withSources() withJavadoc(),
      "org.bitcoinj" % "bitcoinj-core" % "0.12" withSources() withJavadoc() ,
    "org.slf4j" % "slf4j-api" % "1.7.5",
    "org.slf4j" % "slf4j-simple" % "1.7.5"
  )
}               

testOptions += Tests.Argument(TestFrameworks.JUnit, "-q", "-v", "-s", "-a")

parallelExecution in Test := false

logBuffered := false

scalacOptions ++= Seq("-unchecked", "-deprecation", "-feature")

scalacOptions ++= Seq("-Xmax-classfile-name", "255")

scalacOptions in (Compile,doc) ++= Seq("-groups", "-implicits")

here is the error message I am now getting after switching to sbt-assembly version 0.11.2.

java.lang.RuntimeException: deduplicate: different file contents found in the following:
/home/chris/dev/suredbits-core/lib/coinprism-api-assembly-1.2.jar:scala-xml.properties
/home/chris/.ivy2/cache/org.scala-lang.modules/scala-xml_2.11/bundles/scala-xml_2.11-1.0.1.jar:scala-xml.properties
    at sbtassembly.Plugin$Assembly$.sbtassembly$Plugin$Assembly$$applyStrategy$1(Plugin.scala:253)
    at sbtassembly.Plugin$Assembly$$anonfun$15.apply(Plugin.scala:270)
    at sbtassembly.Plugin$Assembly$$anonfun$15.apply(Plugin.scala:267)
    at scala.collection.TraversableLike$$anonfun$flatMap$1.apply(TraversableLike.scala:251)
    at scala.collection.TraversableLike$$anonfun$flatMap$1.apply(TraversableLike.scala:251)
    at scala.collection.Iterator$class.foreach(Iterator.scala:727)
    at scala.collection.AbstractIterator.foreach(Iterator.scala:1157)
    at scala.collection.IterableLike$class.foreach(IterableLike.scala:72)
    at scala.collection.AbstractIterable.foreach(Iterable.scala:54)
    at scala.collection.TraversableLike$class.flatMap(TraversableLike.scala:251)
    at scala.collection.AbstractTraversable.flatMap(Traversable.scala:105)
    at sbtassembly.Plugin$Assembly$.applyStrategies(Plugin.scala:272)
    at sbtassembly.Plugin$Assembly$.x$4$lzycompute$1(Plugin.scala:172)
    at sbtassembly.Plugin$Assembly$.x$4$1(Plugin.scala:170)
    at sbtassembly.Plugin$Assembly$.stratMapping$lzycompute$1(Plugin.scala:170)
    at sbtassembly.Plugin$Assembly$.stratMapping$1(Plugin.scala:170)
    at sbtassembly.Plugin$Assembly$.inputs$lzycompute$1(Plugin.scala:214)
    at sbtassembly.Plugin$Assembly$.inputs$1(Plugin.scala:204)
    at sbtassembly.Plugin$Assembly$.apply(Plugin.scala:230)
    at sbtassembly.Plugin$Assembly$$anonfun$assemblyTask$1.apply(Plugin.scala:373)
    at sbtassembly.Plugin$Assembly$$anonfun$assemblyTask$1.apply(Plugin.scala:370)
    at scala.Function1$$anonfun$compose$1.apply(Function1.scala:47)
    at sbt.$tilde$greater$$anonfun$$u2219$1.apply(TypeFunctions.scala:40)
    at sbt.std.Transform$$anon$4.work(System.scala:63)
    at sbt.Execute$$anonfun$submit$1$$anonfun$apply$1.apply(Execute.scala:226)
    at sbt.Execute$$anonfun$submit$1$$anonfun$apply$1.apply(Execute.scala:226)
    at sbt.ErrorHandling$.wideConvert(ErrorHandling.scala:17)
    at sbt.Execute.work(Execute.scala:235)
    at sbt.Execute$$anonfun$submit$1.apply(Execute.scala:226)
    at sbt.Execute$$anonfun$submit$1.apply(Execute.scala:226)
    at sbt.ConcurrentRestrictions$$anon$4$$anonfun$1.apply(ConcurrentRestrictions.scala:159)
    at sbt.CompletionService$$anon$2.call(CompletionService.scala:28)
    at java.util.concurrent.FutureTask.run(FutureTask.java:262)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
    at java.util.concurrent.FutureTask.run(FutureTask.java:262)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:745)
[error] (*:assembly) deduplicate: different file contents found in the following:
[error] /home/chris/dev/suredbits-core/lib/coinprism-api-assembly-1.2.jar:scala-xml.properties
[error] /home/chris/.ivy2/cache/org.scala-lang.modules/scala-xml_2.11/bundles/scala-xml_2.11-1.0.1.jar:scala-xml.properties
[error] Total time: 72 s, completed Mar 21, 2015 11:22:24 AM

So how do I exclude the dependencies in coin-prism-api jar from conflicing the jars inside of suredbits-core?

1

1 Answers

0
votes

From what I understand one of the libraries you include contains an "xml" scala library and in your project you also use this library (directly or through dependency)

Everything should be fine except you use 2 different versions of this library. Which version of library should sbt-assembly use? If it chooses one version a module using other version won't work.

In your jar you can't have 2 different versions of the same library.