sbt/project/Dependencies.scala

139 lines
6.2 KiB
Scala
Raw Normal View History

2014-12-18 13:57:05 +01:00
import sbt._
import Keys._
import sbt.contraband.ContrabandPlugin.autoImport._
2014-12-18 13:57:05 +01:00
object Dependencies {
// WARNING: Please Scala update versions in PluginCross.scala too
2021-09-17 18:46:07 +02:00
val scala212 = "2.12.15"
2021-05-28 17:36:55 +02:00
val scala213 = "2.13.6"
2020-01-10 14:41:55 +01:00
val checkPluginCross = settingKey[Unit]("Make sure scalaVersion match up")
val baseScalaVersion = scala212
2020-11-14 04:04:48 +01:00
def nightlyVersion: Option[String] =
sys.env.get("BUILD_VERSION") orElse sys.props.get("sbt.build.version")
2014-12-18 23:40:20 +01:00
2015-09-14 09:27:22 +02:00
// sbt modules
2021-12-26 06:28:09 +01:00
private val ioVersion = nightlyVersion.getOrElse("1.6.0")
private val lmVersion =
sys.props.get("sbt.build.lm.version").orElse(nightlyVersion).getOrElse("1.6.1")
2021-12-26 07:44:00 +01:00
val zincVersion = nightlyVersion.getOrElse("1.6.0")
private val sbtIO = "org.scala-sbt" %% "io" % ioVersion
2017-07-16 00:09:40 +02:00
private val libraryManagementCore = "org.scala-sbt" %% "librarymanagement-core" % lmVersion
2019-04-28 23:27:10 +02:00
private val libraryManagementIvy = "org.scala-sbt" %% "librarymanagement-ivy" % lmVersion
2016-11-23 16:17:34 +01:00
val launcherVersion = "1.3.3"
2018-04-07 00:36:10 +02:00
val launcherInterface = "org.scala-sbt" % "launcher-interface" % launcherVersion
val rawLauncher = "org.scala-sbt" % "launcher" % launcherVersion
val testInterface = "org.scala-sbt" % "test-interface" % "1.0"
val ipcSocket = "org.scala-sbt.ipcsocket" % "ipcsocket" % "1.3.1"
2016-11-23 16:17:34 +01:00
private val compilerInterface = "org.scala-sbt" % "compiler-interface" % zincVersion
private val compilerClasspath = "org.scala-sbt" %% "zinc-classpath" % zincVersion
private val compilerApiInfo = "org.scala-sbt" %% "zinc-apiinfo" % zincVersion
private val compilerBridge = "org.scala-sbt" %% "compiler-bridge" % zincVersion
private val zinc = "org.scala-sbt" %% "zinc" % zincVersion
private val zincCompile = "org.scala-sbt" %% "zinc-compile" % zincVersion
2019-04-18 09:14:04 +02:00
private val zincCompileCore = "org.scala-sbt" %% "zinc-compile-core" % zincVersion
2020-01-10 14:41:55 +01:00
def getSbtModulePath(key: String) = {
val localProps = new java.util.Properties()
IO.load(localProps, file("project/local.properties"))
2020-01-10 14:41:55 +01:00
val path = Option(localProps.getProperty(key)).orElse(sys.props.get(key))
path.foreach(f => println(s"Using $key=$f"))
path
}
2020-01-10 14:41:55 +01:00
lazy val sbtIoPath = getSbtModulePath("sbtio.path")
lazy val sbtUtilPath = getSbtModulePath("sbtutil.path")
lazy val sbtLmPath = getSbtModulePath("sbtlm.path")
lazy val sbtZincPath = getSbtModulePath("sbtzinc.path")
2019-04-18 09:14:04 +02:00
def addSbtModule(
path: Option[String],
projectName: String,
moduleId: ModuleID,
c: Option[Configuration] = None
2020-01-10 14:41:55 +01:00
) = (p: Project) => {
2019-04-18 09:14:04 +02:00
val m = moduleId.withConfigurations(c.map(_.name))
path match {
2019-05-13 19:59:58 +02:00
case Some(f) =>
2020-01-10 14:41:55 +01:00
p.dependsOn(ClasspathDependency(ProjectRef(file(f), projectName), c.map(_.name)))
case None => p.settings(libraryDependencies += m, dependencyOverrides += m)
}
2019-04-18 09:14:04 +02:00
}
2020-01-10 14:41:55 +01:00
def addSbtIO = addSbtModule(sbtIoPath, "io", sbtIO)
2020-01-10 14:41:55 +01:00
def addSbtLmCore = addSbtModule(sbtLmPath, "lmCore", libraryManagementCore)
def addSbtLmIvy = addSbtModule(sbtLmPath, "lmIvy", libraryManagementIvy)
def addSbtLmIvyTest = addSbtModule(sbtLmPath, "lmIvy", libraryManagementIvy, Some(Test))
2020-04-22 22:43:11 +02:00
def addSbtCompilerInterface = addSbtModule(sbtZincPath, "compilerInterfaceJVM", compilerInterface)
def addSbtCompilerClasspath = addSbtModule(sbtZincPath, "zincClasspathJVM2_12", compilerClasspath)
def addSbtCompilerApiInfo = addSbtModule(sbtZincPath, "zincApiInfoJVM2_12", compilerApiInfo)
def addSbtCompilerBridge = addSbtModule(sbtZincPath, "compilerBridgeJVM2_12", compilerBridge)
def addSbtZinc = addSbtModule(sbtZincPath, "zincJVM2_12", zinc)
def addSbtZincCompile = addSbtModule(sbtZincPath, "zincCompileJVM2_12", zincCompile)
def addSbtZincCompileCore = addSbtModule(sbtZincPath, "zincCompileCoreJVM2_12", zincCompileCore)
2020-01-10 14:41:55 +01:00
2021-12-18 05:21:26 +01:00
val lmCoursierShaded = "io.get-coursier" %% "lm-coursier-shaded" % "2.0.10"
2020-01-10 14:41:55 +01:00
2020-06-09 06:42:56 +02:00
def sjsonNew(n: String) =
2020-10-19 18:35:58 +02:00
Def.setting("com.eed3si9n" %% n % "0.9.1") // contrabandSjsonNewVersion.value
2020-01-10 14:41:55 +01:00
val sjsonNewScalaJson = sjsonNew("sjson-new-scalajson")
val sjsonNewMurmurhash = sjsonNew("sjson-new-murmurhash")
// JLine 3 version must be coordinated together with JAnsi version
// and the JLine 2 fork version, which uses the same JAnsi
val jline = "org.scala-sbt.jline" % "jline" % "2.14.7-sbt-a1b0ffbb8f64bb820f4f84a0c07a0c0964507493"
val jline3Version = "3.19.0"
val jline3Terminal = "org.jline" % "jline-terminal" % jline3Version
Support scala 2.13 console in thin client In order to make the console task work with scala 2.13 and the thin client, we need to provide a way for the scala repl to use an sbt provided jline3 terminal instead of the default terminal typically built by the repl. We also need to put jline 3 higher up in the classloading hierarchy to ensure that two versions of jline 3 are not loaded (which makes it impossible to share the sbt terminal with the scala terminal). One impact of this change is the decoupling of the version of jline-terminal used by the in process scala console and the version of jline-terminal specified by the scala version itself. It is possible to override this by setting the `useScalaReplJLine` flag to true. When that is set, the scala REPL will run in a fully isolated classloader. That will ensure that the versions are consistent. It will, however, for sure break the thin client and may interfere with the embedded shell ui. As part of this work, I also discovered that jline 3 Terminal.getSize is very slow. In jline 2, the terminal attributes were automatically cached with a timeout of, I think, 1 second so it wasn't a big deal to call Terminal.getAttributes. The getSize method in jline 3 is not cached and it shells out to run a tty command. This caused a significant performance regression in sbt because when progress is enabled, we call Terminal.getSize whenever we log any messages. I added caching of getSize at the TerminalImpl level to address this. The timeout is 1 second, which seems responsive enough for most use cases. We could also move the calculation onto a background thread and have it periodically updated, but that seems like overkill.
2020-07-20 19:12:04 +02:00
val jline3Jansi = "org.jline" % "jline-terminal-jansi" % jline3Version
Fix switching between raw and canonical input There were a number of issues with swithcing between raw and canonical issues that affected both the server and the thin client. These were reported in #5863 and #5856. In both cases, there were issues with reading input or having the input be displayed. Debugging those issues revealed a number of issues with how we were using the jline 3 system terminal and the hybrid interaction with the jline 2 terminal. This commit eliminates all of our internal jline 2 usage. The only remaining jline 2 usage is that we create and override the global terminal for the scala console for scala versions < 2.13. By moving away from jline 2, I was also able to fix #5828, which reported that the home, end and delete keys were not working. One of the big issues that this commit addresses is that the NetworkClient was always performing blocking reads on System.in. This was problematic because it turns out that you can't switch between raw and canonical modes when there is a read present. To fix this, the server now sends a message to the client when it wants to read bytes and only then does the client create a background thread to read a single byte. I also figured out how to set the terminal type properly for the thin client on windows where we had been manually setting the capabilities to ansi, which only worked for some keys. This fix required switching to the WindowsInputStream that I introduced in a prior commit. Before we were using the jline 2 wrapped input stream which was converting some system events, like home and end, to the wrong escape sequence mappings. The remainder of the commit is mostly just converting from jline 2 apis to jline 3 apis. I verified that tab completions, the scala console, the ammonite console and a run task that read from System.in all work with both the server and the thin client on mac, linux and windows after these changes. Fixes #5828, #5863, #5856
2020-09-21 00:27:08 +02:00
val jline3JNA = "org.jline" % "jline-terminal-jna" % jline3Version
Support scala 2.13 console in thin client In order to make the console task work with scala 2.13 and the thin client, we need to provide a way for the scala repl to use an sbt provided jline3 terminal instead of the default terminal typically built by the repl. We also need to put jline 3 higher up in the classloading hierarchy to ensure that two versions of jline 3 are not loaded (which makes it impossible to share the sbt terminal with the scala terminal). One impact of this change is the decoupling of the version of jline-terminal used by the in process scala console and the version of jline-terminal specified by the scala version itself. It is possible to override this by setting the `useScalaReplJLine` flag to true. When that is set, the scala REPL will run in a fully isolated classloader. That will ensure that the versions are consistent. It will, however, for sure break the thin client and may interfere with the embedded shell ui. As part of this work, I also discovered that jline 3 Terminal.getSize is very slow. In jline 2, the terminal attributes were automatically cached with a timeout of, I think, 1 second so it wasn't a big deal to call Terminal.getAttributes. The getSize method in jline 3 is not cached and it shells out to run a tty command. This caused a significant performance regression in sbt because when progress is enabled, we call Terminal.getSize whenever we log any messages. I added caching of getSize at the TerminalImpl level to address this. The timeout is 1 second, which seems responsive enough for most use cases. We could also move the calculation onto a background thread and have it periodically updated, but that seems like overkill.
2020-07-20 19:12:04 +02:00
val jline3Reader = "org.jline" % "jline-reader" % jline3Version
val jline3Builtins = "org.jline" % "jline-builtins" % jline3Version
val jansi = "org.fusesource.jansi" % "jansi" % "2.1.0"
2021-11-14 14:00:10 +01:00
val scalatest = "org.scalatest" %% "scalatest" % "3.2.10"
val scalacheck = "org.scalacheck" %% "scalacheck" % "1.15.4"
val junit = "junit" % "junit" % "4.13.1"
val scalaVerify = "com.eed3si9n.verify" %% "verify" % "1.0.0"
val templateResolverApi = "org.scala-sbt" % "template-resolver" % "0.1"
2016-11-23 16:17:34 +01:00
2021-11-16 02:19:26 +01:00
val scalaXml = Def.setting(
if (scalaBinaryVersion.value == "3") {
"org.scala-lang.modules" %% "scala-xml" % "2.0.1"
} else {
"org.scala-lang.modules" %% "scala-xml" % "1.3.0"
}
)
val scalaParsers = Def.setting(
if (scalaBinaryVersion.value == "3") {
"org.scala-lang.modules" %% "scala-parser-combinators" % "2.1.0"
} else {
"org.scala-lang.modules" %% "scala-parser-combinators" % "1.1.2"
}
)
val scalaReflect = Def.setting(
if (scalaBinaryVersion.value == "3") {
"org.scala-lang" % "scala-reflect" % scala213
} else {
"org.scala-lang" % "scala-reflect" % scalaVersion.value
}
)
2021-01-11 01:23:43 +01:00
val scalaPar = "org.scala-lang.modules" %% "scala-parallel-collections" % "1.0.0"
// specify all of log4j modules to prevent misalignment
def log4jModule = (n: String) => "org.apache.logging.log4j" % n % "2.17.1"
2020-01-10 14:41:55 +01:00
val log4jApi = log4jModule("log4j-api")
val log4jCore = log4jModule("log4j-core")
val log4jSlf4jImpl = log4jModule("log4j-slf4j-impl")
val log4jModules = Vector(log4jApi, log4jCore, log4jSlf4jImpl)
val caffeine = "com.github.ben-manes.caffeine" % "caffeine" % "2.8.5"
val hedgehog = "qa.hedgehog" %% "hedgehog-sbt" % "0.7.0"
val disruptor = "com.lmax" % "disruptor" % "3.4.2"
2021-09-17 18:46:07 +02:00
val kindProjector = ("org.typelevel" % "kind-projector" % "0.13.2").cross(CrossVersion.full)
2014-12-18 13:57:05 +01:00
}