Updates to build for 2.12

This commit is contained in:
Sarah Gerweck 2016-12-06 23:25:12 -08:00
parent 0ecc820132
commit 26bc1f14ca
3 changed files with 73 additions and 50 deletions

View File

@ -49,3 +49,8 @@ end users will be listed here.
#### 0.11.1 #### 0.11.1
* Update to Akka 2.4.11. * Update to Akka 2.4.11.
#### 0.11.2
* Update to Akka 2.4.14.
* Add support for Scala 2.12

View File

@ -62,8 +62,8 @@ object BasicSettings extends AutoPlugin with Basics {
scalaVersion := buildScalaVersion, scalaVersion := buildScalaVersion,
crossScalaVersions := buildScalaVersions, crossScalaVersions := buildScalaVersions,
scalacOptions ++= buildScalacOptions, addScalacOptions(),
javacOptions ++= buildJavacOptions, addJavacOptions(),
autoAPIMappings := true, autoAPIMappings := true,
updateOptions := updateOptions.value.withCachedResolution(cachedResolution), updateOptions := updateOptions.value.withCachedResolution(cachedResolution),
@ -88,30 +88,62 @@ object BasicSettings extends AutoPlugin with Basics {
lazy val buildScalaVersions = buildScalaVersion +: extraScalaVersions lazy val buildScalaVersions = buildScalaVersion +: extraScalaVersions
val buildScalacOptions = Seq ( def addScalacOptions(optim: Boolean = optimize) = Def.derive {
"-unchecked", scalacOptions ++= {
"-feature", val sv = SVer(scalaBinaryVersion.value)
"-target:jvm-" + minimumJavaVersion var options = Seq.empty[String]
) ++ (
if (deprecation) Seq("-deprecation") else Seq.empty
) ++ (
if (optimize) Seq("-optimize") else Seq.empty
) ++ (
if (inlineWarn) Seq("-Yinline-warnings") else Seq.empty
) ++ (
if (unusedWarn) Seq("-Ywarn-unused") else Seq.empty
) ++ (
if (importWarn) Seq("-Ywarn-unused-import") else Seq.empty
) ++ (
if (newBackend) Seq("-Ybackend:GenBCode", "-Yopt:l:classpath") else Seq.empty
)
/* Java build setup */ options :+= "-unchecked"
val buildJavacOptions = Seq( options :+= "-feature"
if (deprecation) {
options :+= "-deprecation"
}
if (inlineWarn) {
options :+= "-Yinline-warnings"
}
if (unusedWarn) {
options :+= "-Ywarn-unused"
}
if (importWarn) {
options :+= "-Ywarn-unused-import"
}
if (!sv.requireJava8) {
options :+= "-target:jvm-" + minimumJavaVersion
}
if (optim) {
if (sv.newOptimize || sv.supportsNewBackend && newBackend) {
options :+= "-opt:l:project"
} else if (!sv.requireJava8) {
options :+= "-optimize"
}
}
if (sv.supportsNewBackend && newBackend && !sv.requireJava8) {
options :+= "-Ybackend:GenBCode"
}
options
}
}
def addJavacOptions() = Def.derive {
javacOptions ++= {
val sv = SVer(scalaBinaryVersion.value)
var options = Seq.empty[String]
if (sv.requireJava8) {
options ++= Seq[String](
"-target", "1.8",
"-source", "1.8"
)
} else {
options ++= Seq[String](
"-target", minimumJavaVersion, "-target", minimumJavaVersion,
"-source", minimumJavaVersion "-source", minimumJavaVersion
) ++ (
if (deprecation) Seq("-Xlint:deprecation") else Seq.empty
) )
} }
options
}
}
}

View File

@ -20,41 +20,27 @@ object Helpers {
} }
sealed trait SVer { sealed trait SVer {
def requireJava8: Boolean val supportsNewBackend: Boolean = false
val requireJava8: Boolean = true
val newOptimize: Boolean = false
} }
object SVer { object SVer {
def apply(scalaVersion: String): SVer = { def apply(scalaVersion: String): SVer = {
scalaVersion match { scalaVersion match {
case "2.10" => SVer2_10 case "2.10" => SVer2_10
case "2.11" => SVer2_11 case "2.11" => SVer2_11
case "2.12.0-M1" => SVer2_12M1
case "2.12.0-M2" => SVer2_12M2
case "2.12.0-M3" => SVer2_12M3
case "2.12.0-M4" => SVer2_12M4
case "2.12" => SVer2_12 case "2.12" => SVer2_12
} }
} }
} }
case object SVer2_10 extends SVer { case object SVer2_10 extends SVer {
def requireJava8 = false override val requireJava8 = false
} }
case object SVer2_11 extends SVer { case object SVer2_11 extends SVer {
def requireJava8 = false override val supportsNewBackend = true
} override val requireJava8 = false
case object SVer2_12M1 extends SVer {
def requireJava8 = true
}
case object SVer2_12M2 extends SVer {
def requireJava8 = true
}
case object SVer2_12M3 extends SVer {
def requireJava8 = true
}
case object SVer2_12M4 extends SVer {
def requireJava8 = true
} }
case object SVer2_12 extends SVer { case object SVer2_12 extends SVer {
def requireJava8 = true override val newOptimize = true
} }
} }