Skip to content

Commit

Permalink
Cross build for Scala 2.12
Browse files Browse the repository at this point in the history
Problem

There exists a need to publish artifacts that are
binary compatibility with Scala 2.12.

Solution

- Modify sbt build defintion to cross build for 2.12.
- Modify main and test sources to compile against 2.12.
- Ensure the use of scoverage artifacts that exist when targeting
  2.12.

Result

- When targeting 2.12, the scoverage artifacts will still use their
  2.11 versions.
- By default, scoverage is disabled when targeting 2.12 and for the
  scrooge-sbt-plugin.

Signed-off-by: Ruben Oanta <roanta@twitter.com>

RB_ID=844799
  • Loading branch information
jeffreyolchovy authored and jenkins committed Jun 27, 2016
1 parent 08cd8ac commit 12472db
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
22 changes: 20 additions & 2 deletions project/Build.scala
Expand Up @@ -57,13 +57,30 @@ object Scrooge extends Build {
"sonatype-public" at "https://oss.sonatype.org/content/groups/public"
),

ScoverageSbtPlugin.ScoverageKeys.coverageHighlighting := true,

libraryDependencies ++= Seq(
"org.scalatest" %% "scalatest" % "2.2.6" % "test",
"org.scalacheck" %% "scalacheck" % "1.12.5" % "test",
"junit" % "junit" % "4.12" % "test"
),

// scoverage automatically brings in libraries on our behalf, but it hasn't
// been updated for 2.12 yet[0]. for now, we need to rely on the 2.11 ones
// (which seem to work OK)
//
// [0]: https://github.com/scoverage/sbt-scoverage/issues/126
libraryDependencies := {
libraryDependencies.value.map {
case moduleId: ModuleID
if moduleId.organization == "org.scoverage"
&& scalaVersion.value.startsWith("2.12") =>
moduleId.copy(name = moduleId.name.replace(scalaVersion.value, "2.11"))
case moduleId =>
moduleId
}
},

ScoverageSbtPlugin.ScoverageKeys.coverageHighlighting := true,

resolvers += "twitter-repo" at "https://maven.twttr.com",

// Sonatype publishing
Expand Down Expand Up @@ -112,6 +129,7 @@ object Scrooge extends Build {
sharedSettingsWithoutScalaVersion ++
Seq(
scalaVersion := "2.11.8",
crossScalaVersions := Seq("2.11.8", "2.12.0-M4"),
scalacOptions := Seq(
"-deprecation",
"-unchecked",
Expand Down
Expand Up @@ -69,4 +69,4 @@ private[scrooge] class ScalaObjectHandler extends ReflectionObjectHandler {
}
}
}
}
}

0 comments on commit 12472db

Please sign in to comment.