vkubicki
vkubicki

Reputation: 1124

Sbt assembly for multiple targets

I need to create fat jars for multiple version of scala using sbt assembly.

When I target a single version, I write in simple.sbt:

scalaVersion := "2.11.12"

And the fat jar is output to target/scala-2.11/Kernalytics-assembly-1.0.jar. Now I would like to also target Scala 2.12. I could edit the sbt file to change scalaVersion, but I would like the assembly process to be automated over a range of versions of Scala when I call sbt assembly.

If I use crossScalaVersions:

name := "Kernalytics"

version := "1.0"

crossScalaVersions := Seq("2.11.12", "2.12.4")

libraryDependencies  ++= Seq(
  "org.scalanlp" %% "breeze" % "0.13.2",
  "org.scalanlp" %% "breeze-natives" % "0.13.2",
  "org.scalanlp" %% "breeze-viz" % "0.13.2"
)

libraryDependencies += "commons-io" % "commons-io" % "2.6"

resolvers += "Sonatype Releases" at "https://oss.sonatype.org/content/repositories/releases/"

libraryDependencies += "org.scalactic" %% "scalactic" % "3.0.4"
libraryDependencies += "org.scalatest" %% "scalatest" % "3.0.4" % "test"

The only output is target/scala-2.12/Kernalytics-assembly-1.0.jar

Upvotes: 4

Views: 982

Answers (1)

Simon Groenewolt
Simon Groenewolt

Reputation: 10665

If you use crossScalaVersions I think you need to prefix the command with a '+' if you want to build for all versions.

From Cross-Building a Project:

To build against all versions listed in crossScalaVersions, prefix the action to run with +

Upvotes: 4

Related Questions