turbo mode

This creates a performance mode that enables experimental or advanced features that might require some debugging by the build user when it doesn't work.

Initially we are putting the layered ClassLoader (`ClassLoaderLayeringStrategy.AllLibraryJars`) behind this flag.
This commit is contained in:
Eugene Yokota 2019-06-08 17:49:06 +02:00
parent 006722f81c
commit 6878fb6cdb
9 changed files with 23 additions and 4 deletions

View File

@ -164,7 +164,6 @@ object Defaults extends BuildCommon {
private[sbt] lazy val globalJvmCore: Seq[Setting[_]] =
Seq(
compilerCache := state.value get Keys.stateCompilerCache getOrElse CompilerCache.fresh,
classLoaderLayeringStrategy :== ClassLoaderLayeringStrategy.AllLibraryJars,
sourcesInBase :== true,
autoAPIMappings := false,
apiMappings := Map.empty,
@ -285,6 +284,7 @@ object Defaults extends BuildCommon {
val tempDirectory = taskTemporaryDirectory.value
() => Clean.deleteContents(tempDirectory, _ => false)
},
turbo :== SysProp.turbo,
useSuperShell := { if (insideCI.value) false else SysProp.supershell },
progressReports := {
val progress = useSuperShell.value
@ -1049,7 +1049,7 @@ object Defaults extends BuildCommon {
cp,
forkedParallelExecution = false,
javaOptions = Nil,
strategy = ClassLoaderLayeringStrategy.AllLibraryJars,
strategy = ClassLoaderLayeringStrategy.ScalaLibrary,
projectId = "",
)
}
@ -1072,7 +1072,7 @@ object Defaults extends BuildCommon {
cp,
forkedParallelExecution,
javaOptions = Nil,
strategy = ClassLoaderLayeringStrategy.AllLibraryJars,
strategy = ClassLoaderLayeringStrategy.ScalaLibrary,
projectId = "",
)
}
@ -1886,7 +1886,11 @@ object Defaults extends BuildCommon {
}
val base = ModuleID(id.groupID, id.name, sv).withCrossVersion(cross)
CrossVersion(scalaV, binVersion)(base).withCrossVersion(Disabled())
}
},
classLoaderLayeringStrategy := {
if (turbo.value) ClassLoaderLayeringStrategy.AllLibraryJars
else ClassLoaderLayeringStrategy.ScalaLibrary
},
)
// build.sbt is treated a Scala source of metabuild, so to enable deprecation flag on build.sbt we set the option here.
lazy val deprecationSettings: Seq[Setting[_]] =

View File

@ -474,6 +474,7 @@ object Keys {
def apply(progress: ExecuteProgress[Task]): TaskProgress = new TaskProgress(progress)
}
val useSuperShell = settingKey[Boolean]("Enables (true) or disables the super shell.")
val turbo = settingKey[Boolean]("Enables (true) or disables optional performance features.")
// This key can be used to add custom ExecuteProgress instances
val progressReports = settingKey[Seq[TaskProgress]]("A function that returns a list of progress reporters.").withRank(DTask)
private[sbt] val postProgressReports = settingKey[Unit]("Internally used to modify logger.").withRank(DTask)

View File

@ -93,6 +93,8 @@ object SysProp {
coursierOpt.orElse(notIvyOpt).getOrElse(true)
}
def turbo: Boolean = getOrFalse("sbt.turbo")
def taskTimings: Boolean = getOrFalse("sbt.task.timings")
def taskTimingsOnShutdown: Boolean = getOrFalse("sbt.task.timings.on.shutdown")
def taskTimingsThreshold: Long = long("sbt.task.timings.threshold", 0L)

View File

@ -1,3 +1,5 @@
ThisBuild / turbo := true
val akkaTest = (project in file(".")).settings(
name := "akka-test",
scalaVersion := "2.12.8",

View File

@ -10,6 +10,8 @@ val wrappedTest = taskKey[Unit]("Test with modified java.library.path")
def wrap(task: InputKey[Unit]): Def.Initialize[Task[Unit]] =
Def.sequential(appendToLibraryPath, task.toTask(""), dropLibraryPath)
ThisBuild / turbo := true
val root = (project in file(".")).settings(
scalaVersion := "2.12.8",
javacOptions ++= Seq("-source", "1.8", "-target", "1.8", "-h",

View File

@ -1,3 +1,5 @@
ThisBuild / turbo := true
val snapshot = (project in file(".")).settings(
name := "mismatched-libraries",
scalaVersion := "2.12.8",

View File

@ -1,3 +1,5 @@
ThisBuild / turbo := true
resolvers += "Local Maven" at (baseDirectory.value / "libraries" / "foo" / "ivy").toURI.toURL.toString
libraryDependencies += "sbt" %% "foo-lib" % "0.1.0"

View File

@ -1,3 +1,5 @@
ThisBuild / turbo := true
import java.nio.file.Files
import java.nio.file.attribute.FileTime
import scala.collection.JavaConverters._

View File

@ -1,3 +1,5 @@
ThisBuild / turbo := true
val utestTest = (project in file(".")).settings(
name := "utest-test",
scalaVersion := "2.12.8",