Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to fallback Scala version for SBT dependencies?

Tags:

scala

sbt

I have dependencies in my build.sbt that don't have specific builds for the Scala 2.9.0-1 I'm using, instead I'm supposed to use the build for 2.9.0. How to configure the build so that it determines that without specifying the exact version for each dependency? For instance subcut doesn't have a build for 2.9.0-1.

Some lines off my build.sbt:

...
scalaVersion := "2.9.0-1"
libraryDependencies ++= Seq(
  "org.scala-tools" %% "subcut" % "0.8"
)
...

I'd rather avoid this:

  "org.scala-tools" % "subcut_2.9.0" % "0.8"

Something along the lines of specifying multiple versions it'd try in the specified order.

like image 327
hleinone Avatar asked Jul 05 '11 21:07

hleinone


1 Answers

Here's what I've done:

libraryDependencies <++= (scalaVersion) { (v) =>
  val scalaVersionString = v match {
    case "2.9.0-1" => "2.9.0"
    case _ => v
  }
  Seq(
    "org.scala-tools.testing" % ("scalacheck_" + scalaVersionString) % "1.8" % "test" withSources,
    "org.specs2" %% "specs2" % "1.3" % "test" withSources,
    "com.github.dmlap" %% "sizeof" % "0.1" % "test" from "http://cloud.github.com/downloads/dmlap/jvm-sizeof/jvm-sizeof-0.1.jar"
  )
}
like image 62
Eugene Yokota Avatar answered Oct 17 '22 04:10

Eugene Yokota