Sbt: Cross-compile in multiproject setup


I would like to have an sbt build involving the following subprojects:

  • foo-shared
    crossScalaVersions := Seq("2.11.12", "2.12.4")
  • foo-app (2.12, depends on foo-shared)
    scalaVersion := "2.12.4"
  • foo-spark (2.11, depends on foo-shared)
    scalaVersion := "2.11.12"

Independently of each other, the project tests and builds already seem to work with this naive setup, i.e. I can do

++ 2.11.12


++ 2.12.4

However, there’s a few remaining issues:

  • How can I run the full tests for all projects at once? If I just do sbt test, the fooSpark tests will fail due to a NoSuchMethodError, apparently due to picking up the wrong version of fooShared.
  • How can I trigger the builds in Jenkins, i.e. how would I orchestrate ++ <version> or equivalent from the outside?

I’m still wondering whether my overall approach makes sense. I’m not entirely fluent in multiproject builds, yet, and this is my first venture into cross-compiling, and I haven’t found much information on the combination of the two. (May just be a lack of Google fu on my side, though.) Any hints, pointers and suggestions appreciated.