-
-
Notifications
You must be signed in to change notification settings - Fork 38
/
Copy pathScalaVer.scala
40 lines (28 loc) · 1.13 KB
/
ScalaVer.scala
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import sbt._
import Keys._
sealed abstract class ScalaVer(val full: String)
object ScalaVer {
case object _211 extends ScalaVer("2.11.12")
case object _212 extends ScalaVer("2.12.20")
case object _213 extends ScalaVer("2.13.14")
val values: Seq[ScalaVer] = Set(_213, _212, _211).toSeq
val default: ScalaVer = _212
def fromEnv: Option[ScalaVer] = sys.env.get("SCALA_VER") flatMap fromString
def fromString(full: String): Option[ScalaVer] = full match {
case x if x startsWith "2.11" => Some(_211)
case x if x startsWith "2.12" => Some(_212)
case x if x startsWith "2.13" => Some(_213)
case _ => None
}
lazy val scalaV = settingKey[ScalaVer]("Current Scala Version").withRank(KeyRanks.Invisible)
def settings = Seq(
scalaVersion := (ScalaVer.fromEnv getOrElse ScalaVer.default).full,
crossScalaVersions := ScalaVer.values.map(_.full),
scalaV := ScalaVer.fromString(scalaVersion.value) getOrElse ScalaVer.default
)
def settings213 = Seq(
scalaVersion := _213.full,
crossScalaVersions := Seq(_213.full),
scalaV := _213
)
}