Skip to content

Instantly share code, notes, and snippets.

@ymasory
Last active December 12, 2015 07:18
Show Gist options
  • Save ymasory/4735020 to your computer and use it in GitHub Desktop.
Save ymasory/4735020 to your computer and use it in GitHub Desktop.
Dealing with SIP-18 (language imports) in the presence of cross-compilation in build.sbt
scalaVersion := "2.10.0"
// Let's support all "modern" Scala versions.
crossScalaVersions := Seq(
"2.9.3-RC1",
"2.9.2",
"2.9.1", "2.9.1-1",
"2.9.0", "2.9.0-1",
"2.8.0", "2.8.1", "2.8.2"
)
// These options will be used for *all* versions.
scalacOptions ++= Seq(
"-deprecation",
"-unchecked"
)
// These language flags will be used only for 2.10.x.
// Uncomment those you need, or if you hate SIP-18, all of them.
// Do you know a more future-proof way to compare Scala version strings?
// Please let me know!
// Suggestion from Mike Pilquist: https://github.com/cjmx/cjmx/blob/master/build.sbt#L24
scalacOptions <++= scalaVersion map { sv =>
if (sv startsWith "2.10") List(
"-feature"
// "-language:postfixOps",
// "-language:reflectiveCalls",
// "-language:implicitConversions"
// "-language:higherKinds",
// "-language:existentials",
// "-language:experimental.macros",
// "-language:experimental.dynamics"
)
else Nil
}
@ymasory
Copy link
Author

ymasory commented Feb 7, 2013

Good point @aloiscochard, thanks. This gist will only work in cases that you're not using 2.10 features and are merely trying to support 2.10.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment