We have a project with several subprojects which can compile under both Scala 2.10 and 2.11, one subproject which only compiles under 2.10 (actually, Scala-Virtualized 2.10.
I had a similar question. My question had an additional complication of classpath dependencies (dependsOn
), rather than just aggregation, but one solution for my problem fixes this one quite well.
sbt-doge, a deceptively cutesy GitHub project, replaces the implementation of +
with one of its interchangeable prefixes: much, so, such, very.
Current implementation of + cross building operator does not take in account for the crossScalaVersions of the sub projects. Until that's fixed, here's an alternative implementation of it.
The creator of the project is one of the main contributors to SBT.
Add
addSbtPlugin("com.eed3si9n" % "sbt-doge" % "0.1.3")
to project/plugins.sbt
.
Then
> very compile
I believe sbt-doge
might not be enough for your requirements as mine were not met by this plugin as well.
I would recommend sbt-cross
This plugin allows you for much more flexibility among your modules, as well as, it provides a way to aggregate
modules of different Scala versions, without the need to have any version in common!
Example:
lazy val common = (project in file("common")).cross
lazy val common_2_11 = common("2.11.8")
lazy val common_2_10 = common("2.10.6")
lazy val A = (project in file("A"))
.settings(scalaVersion := "2.10.6")
.dependsOn(common_2_10)
lazy val B = (project in file("B"))
.settings(scalaVersion := "2.11.8")
.dependsOn(common_2_11)
lazy val root = (project in file("."))
.aggregate(common, A, B)
I have already posted a similar answer.
Enjoy!