enso/build.sbt

856 lines
35 KiB
Plaintext
Raw Normal View History

import java.io.File
2019-09-10 19:53:23 +03:00
import org.enso.build.BenchTasks._
import org.enso.build.WithDebugCommand
import sbt.Keys.scalacOptions
import sbt.addCompilerPlugin
2019-11-05 17:12:33 +03:00
import sbtassembly.AssemblyPlugin.defaultUniversalScript
2019-11-26 16:02:50 +03:00
import sbtcrossproject.CrossPlugin.autoImport.{crossProject, CrossType}
2019-08-28 18:40:08 +03:00
import scala.sys.process._
2020-04-30 22:30:55 +03:00
// ============================================================================
// === Global Configuration ===================================================
// ============================================================================
2019-06-07 14:49:47 +03:00
2020-04-30 22:30:55 +03:00
val scalacVersion = "2.13.2"
2020-05-21 13:46:06 +03:00
val graalVersion = "20.1.0"
val ensoVersion = "0.0.1"
2019-09-12 17:47:25 +03:00
organization in ThisBuild := "org.enso"
scalaVersion in ThisBuild := scalacVersion
2020-04-30 22:30:55 +03:00
val coursierCache = file("~/.cache/coursier/v1")
2019-09-12 17:47:25 +03:00
2019-10-29 17:32:50 +03:00
Global / onChangedBuildSource := ReloadOnSourceChanges
2020-04-30 22:30:55 +03:00
// ============================================================================
// === Compiler Options =======================================================
// ============================================================================
2019-09-12 17:47:25 +03:00
javacOptions in ThisBuild ++= Seq(
2020-02-13 17:33:39 +03:00
"-encoding", // Provide explicit encoding (the next line)
"UTF-8", // Specify character encoding used by Java source files.
"-deprecation" // Shows a description of each use or override of a deprecated member or class.
)
2019-09-12 17:47:25 +03:00
scalacOptions in ThisBuild ++= Seq(
"-deprecation", // Emit warning and location for usages of deprecated APIs.
"-encoding", // Provide explicit encoding (the next line)
"utf-8", // Specify character encoding used by Scala source files.
2019-09-12 17:47:25 +03:00
"-explaintypes", // Explain type errors in more detail.
"-feature", // Emit warning and location for usages of features that should be imported explicitly.
"-language:existentials", // Existential types (besides wildcard types) can be written and inferred
"-language:experimental.macros", // Allow macro definition (besides implementation and application)
"-language:higherKinds", // Allow higher-kinded types
"-language:implicitConversions", // Allow definition of implicit functions called views
"-unchecked", // Enable additional warnings where generated code depends on assumptions.
2019-11-18 14:18:16 +03:00
"-Xcheckinit", // Wrap field accessors to throw an exception on uninitialized access.
2019-09-12 17:47:25 +03:00
"-Xlint:adapted-args", // Warn if an argument list is modified to match the receiver.
"-Xlint:constant", // Evaluation of a constant arithmetic expression results in an error.
"-Xlint:delayedinit-select", // Selecting member of DelayedInit.
"-Xlint:doc-detached", // A Scaladoc comment appears to be detached from its element.
"-Xlint:inaccessible", // Warn about inaccessible types in method signatures.
"-Xlint:infer-any", // Warn when a type argument is inferred to be `Any`.
"-Xlint:missing-interpolator", // A string literal appears to be missing an interpolator id.
"-Xlint:nullary-override", // Warn when non-nullary `def f()' overrides nullary `def f'.
"-Xlint:nullary-unit", // Warn when nullary methods return Unit.
"-Xlint:option-implicit", // Option.apply used implicit view.
"-Xlint:package-object-classes", // Class or object defined in package object.
"-Xlint:poly-implicit-overload", // Parameterized overloaded implicit methods are not visible as view bounds.
"-Xlint:private-shadow", // A private field (or class parameter) shadows a superclass field.
"-Xlint:stars-align", // Pattern sequence wildcard must align with sequence component.
2020-02-13 17:33:39 +03:00
"-Xlint:type-parameter-shadow", // A local type parameter shadows a type already in scope.
2019-11-18 14:18:16 +03:00
"-Xmacro-settings:-logging@org.enso", // Disable the debug logging globally.
2019-09-12 17:47:25 +03:00
"-Ywarn-dead-code", // Warn when dead code is identified.
"-Ywarn-extra-implicit", // Warn when more than one implicit parameter section is defined.
"-Ywarn-numeric-widen", // Warn when numerics are widened.
"-Ywarn-unused:imports", // Warn if an import selector is not referenced.
2020-02-13 17:33:39 +03:00
"-Ywarn-unused:implicits", // Warn if an implicit parameter is unused.
2019-09-12 17:47:25 +03:00
"-Ywarn-unused:locals", // Warn if a local definition is unused.
"-Ywarn-unused:patvars", // Warn if a variable bound in a pattern is unused.
"-Ywarn-unused:privates", // Warn if a private member is unused.
2020-04-30 22:30:55 +03:00
"-Ywarn-unused:params", // Warn if a value parameter is unused.
"-Xfatal-warnings" // Make warnings fatal so they don't make it onto main (use @nowarn for local suppression)
2020-04-30 22:30:55 +03:00
)
val jsSettings = Seq(
scalaJSLinkerConfig ~= { _.withModuleKind(ModuleKind.ESModule) }
)
scalacOptions in (Compile, console) ~= (_ filterNot (_ == "-Xfatal-warnings"))
2020-04-30 22:30:55 +03:00
// ============================================================================
// === Benchmark Configuration ================================================
// ============================================================================
2019-09-10 19:53:23 +03:00
lazy val Benchmark = config("bench") extend sbt.Test
// Native Image Generation
2019-08-28 18:40:08 +03:00
lazy val buildNativeImage =
taskKey[Unit]("Build native image for the Enso executable")
2019-06-07 14:49:47 +03:00
2020-04-30 22:30:55 +03:00
// ============================================================================
// === Global Project =========================================================
// ============================================================================
2019-09-12 17:47:25 +03:00
lazy val enso = (project in file("."))
.settings(version := "0.1")
.aggregate(
`language-server`,
`parser-service`,
`polyglot-api`,
`project-manager`,
`syntax-definition`.jvm,
`text-buffer`,
flexer.jvm,
2020-01-24 21:56:52 +03:00
graph,
logger.jvm,
pkg,
runner,
runtime,
syntax.jvm
)
2019-09-12 17:47:25 +03:00
.settings(Global / concurrentRestrictions += Tags.exclusive(Exclusive))
2020-04-30 22:30:55 +03:00
// ============================================================================
// === Dependency Versions ====================================================
// ============================================================================
2019-09-12 17:47:25 +03:00
2020-04-30 22:30:55 +03:00
/* Note [Dependency Versions]
* ~~~~~~~~~~~~~~~~~~~~~~~~~~
* Please maintain the following section in alphabetical order for the bundles
* of dependencies. Additionally, please keep the 'Other' subsection in
* alphabetical order.
*
* Furthermore, please keep the following in mind:
* - Wherever possible, we should use the same version of a dependency
* throughout the project.
* - If you need to include a new dependency, please define its version in this
* section.
* - If that version is not the latest, please include a note explaining why
* this is the case.
* - If, for some reason, you need to use a dependency version other than the
* global one, please include a note explaining why this is the case, and the
* circumstances under which the dependency could be upgraded to use the
* global version
*/
2020-04-30 22:30:55 +03:00
// === Akka ===================================================================
2020-02-13 17:33:39 +03:00
2020-04-30 22:30:55 +03:00
def akkaPkg(name: String) = akkaURL %% s"akka-$name" % akkaVersion
def akkaHTTPPkg(name: String) = akkaURL %% s"akka-$name" % akkaHTTPVersion
val akkaURL = "com.typesafe.akka"
val akkaVersion = "2.6.4"
val akkaHTTPVersion = "10.2.0-M1"
val akkaMockSchedulerVersion = "0.5.5"
val akkaActor = akkaPkg("actor")
val akkaStream = akkaPkg("stream")
val akkaTyped = akkaPkg("actor-typed")
val akkaTestkit = akkaPkg("testkit")
val akkaSLF4J = akkaPkg("slf4j")
val akkaTestkitTyped = akkaPkg("actor-testkit-typed") % Test
val akkaHttp = akkaHTTPPkg("http")
val akkaSpray = akkaHTTPPkg("http-spray-json")
val akka =
Seq(akkaActor, akkaStream, akkaHttp, akkaSpray, akkaTyped)
// === Cats ===================================================================
val catsVersion = "2.2.0-M1"
val kittensVersion = "2.1.0"
2019-09-12 17:47:25 +03:00
val cats = {
Seq(
2020-02-13 17:33:39 +03:00
"org.typelevel" %% "cats-core" % catsVersion,
"org.typelevel" %% "cats-effect" % catsVersion,
"org.typelevel" %% "cats-free" % catsVersion,
"org.typelevel" %% "cats-macros" % catsVersion,
2020-04-30 22:30:55 +03:00
"org.typelevel" %% "kittens" % kittensVersion
)
2019-09-12 17:47:25 +03:00
}
2020-04-30 22:30:55 +03:00
// === Circe ==================================================================
2019-09-12 17:47:25 +03:00
2020-04-30 22:30:55 +03:00
val circeVersion = "0.13.0"
val circeYamlVersion = "0.12.0"
val enumeratumCirceVersion = "1.5.23"
val circe = Seq("circe-core", "circe-generic", "circe-parser")
.map("io.circe" %% _ % circeVersion)
2019-09-12 17:47:25 +03:00
2020-04-30 22:30:55 +03:00
// === Commons ================================================================
val commonsCollectionsVersion = "4.4"
val commonsLangVersion = "3.10"
val commonsIoVersion = "2.6"
val commonsTextVersion = "1.8"
val commonsMathVersion = "3.6.1"
val commonsCompressVersion = "1.20"
val commonsCliVersion = "1.4"
val commons = Seq(
"org.apache.commons" % "commons-collections4" % commonsCollectionsVersion,
"org.apache.commons" % "commons-lang3" % commonsLangVersion,
"commons-io" % "commons-io" % commonsIoVersion,
"org.apache.commons" % "commons-text" % commonsTextVersion,
"org.apache.commons" % "commons-math3" % commonsMathVersion,
"commons-cli" % "commons-cli" % commonsCliVersion
)
// === Jackson ================================================================
2019-09-12 17:47:25 +03:00
2020-04-30 22:30:55 +03:00
val jacksonVersion = "2.10.3"
val jackson = Seq(
"com.fasterxml.jackson.dataformat" % "jackson-dataformat-cbor" % jacksonVersion,
"com.fasterxml.jackson.core" % "jackson-databind" % jacksonVersion,
"com.fasterxml.jackson.module" %% "jackson-module-scala" % jacksonVersion
)
// === JMH ====================================================================
2019-09-12 17:47:25 +03:00
2020-04-30 22:30:55 +03:00
val jmhVersion = "1.23"
2019-09-12 17:47:25 +03:00
val jmh = Seq(
2020-04-30 22:30:55 +03:00
"org.openjdk.jmh" % "jmh-core" % jmhVersion % Benchmark,
"org.openjdk.jmh" % "jmh-generator-annprocess" % jmhVersion % Benchmark
2019-09-12 17:47:25 +03:00
)
2019-06-07 14:49:47 +03:00
2020-04-30 22:30:55 +03:00
// === Monocle ================================================================
2019-11-18 14:18:16 +03:00
2020-04-30 22:30:55 +03:00
val monocleVersion = "2.0.4"
val monocle = {
Seq(
"com.github.julien-truffaut" %% "monocle-core" % monocleVersion,
"com.github.julien-truffaut" %% "monocle-macro" % monocleVersion,
"com.github.julien-truffaut" %% "monocle-law" % monocleVersion % "test"
)
}
2019-09-12 17:47:25 +03:00
2020-04-30 22:30:55 +03:00
// === Scala Compiler =========================================================
val scalaCompiler = Seq(
"org.scala-lang" % "scala-reflect" % scalacVersion,
"org.scala-lang" % "scala-compiler" % scalacVersion
)
// === Splain =================================================================
val splainVersion = "0.5.4"
val splainOptions = Seq(
"-P:splain:infix:true",
"-P:splain:foundreq:true",
"-P:splain:implicits:true",
"-P:splain:tree:true"
)
2020-04-30 22:30:55 +03:00
// === ZIO ====================================================================
val zioVersion = "1.0.0-RC18-2"
val zioInteropCatsVersion = "2.0.0.0-RC13"
val zio = Seq(
"dev.zio" %% "zio" % zioVersion,
"dev.zio" %% "zio-interop-cats" % zioInteropCatsVersion
)
// === Other ==================================================================
val bcpkixJdk15Version = "1.65"
val declineVersion = "1.2.0"
val directoryWatcherVersion = "0.9.9"
val flatbuffersVersion = "1.12.0"
val guavaVersion = "29.0-jre"
val jlineVersion = "3.14.1"
val jupyterJvmBasekernelVersion = "2.3.0"
val kindProjectorVersion = "0.11.0"
val logbackClassicVersion = "1.2.3"
val mockitoScalaVersion = "1.14.0"
val newtypeVersion = "0.4.3"
val pprintVersion = "0.5.9"
val pureconfigVersion = "0.12.2"
val refinedVersion = "0.9.14"
val scalacheckVersion = "1.14.3"
val scalacticVersion = "3.3.0-SNAP2"
val scalaLoggingVersion = "3.9.2"
val scalameterVersion = "0.19"
val scalatagsVersion = "0.9.0"
val scalatestVersion = "3.3.0-SNAP2"
val shapelessVersion = "2.4.0-M1"
val tikaVersion = "1.24.1"
val typesafeConfigVersion = "1.4.0"
// ============================================================================
// === Internal Libraries =====================================================
// ============================================================================
2019-11-26 16:02:50 +03:00
lazy val logger = crossProject(JVMPlatform, JSPlatform)
.withoutSuffixFor(JVMPlatform)
.crossType(CrossType.Pure)
.in(file("lib/logger"))
2019-06-07 14:39:30 +03:00
.settings(
2019-09-12 17:47:25 +03:00
version := "0.1",
2020-04-30 22:30:55 +03:00
libraryDependencies ++= scalaCompiler
)
.jsSettings(jsSettings)
2019-09-12 17:47:25 +03:00
2019-11-26 16:02:50 +03:00
lazy val flexer = crossProject(JVMPlatform, JSPlatform)
.withoutSuffixFor(JVMPlatform)
.crossType(CrossType.Pure)
.in(file("lib/flexer"))
2019-09-12 17:47:25 +03:00
.dependsOn(logger)
.settings(
2019-09-12 17:47:25 +03:00
version := "0.1",
resolvers += Resolver.sonatypeRepo("releases"),
2020-04-30 22:30:55 +03:00
libraryDependencies ++= scalaCompiler ++ Seq(
"com.google.guava" % "guava" % guavaVersion,
2020-02-13 17:33:39 +03:00
"org.typelevel" %%% "cats-core" % catsVersion,
2020-04-30 22:30:55 +03:00
"org.typelevel" %%% "kittens" % kittensVersion
)
)
.jsSettings(jsSettings)
2019-09-12 17:47:25 +03:00
lazy val `syntax-definition` = crossProject(JVMPlatform, JSPlatform)
2019-11-26 16:02:50 +03:00
.withoutSuffixFor(JVMPlatform)
.crossType(CrossType.Pure)
.in(file("lib/syntax/definition"))
2019-09-12 17:47:25 +03:00
.dependsOn(logger, flexer)
.settings(
scalacOptions ++= Seq("-Ypatmat-exhaust-depth", "off"),
2020-04-30 22:30:55 +03:00
libraryDependencies ++= monocle ++ scalaCompiler ++ Seq(
2020-02-13 17:33:39 +03:00
"org.typelevel" %%% "cats-core" % catsVersion,
2020-04-30 22:30:55 +03:00
"org.typelevel" %%% "kittens" % kittensVersion,
"com.lihaoyi" %%% "scalatags" % scalatagsVersion,
2019-11-26 16:02:50 +03:00
"io.circe" %%% "circe-core" % circeVersion,
"io.circe" %%% "circe-generic" % circeVersion,
"io.circe" %%% "circe-parser" % circeVersion
2019-09-12 17:47:25 +03:00
)
2019-06-03 05:09:26 +03:00
)
.jsSettings(jsSettings)
2019-09-12 17:47:25 +03:00
2019-11-26 16:02:50 +03:00
lazy val syntax = crossProject(JVMPlatform, JSPlatform)
.withoutSuffixFor(JVMPlatform)
.crossType(CrossType.Full)
.in(file("lib/syntax/specialization"))
.dependsOn(logger, flexer, `syntax-definition`)
2019-09-12 17:47:25 +03:00
.configs(Test)
.configs(Benchmark)
.settings(
2019-11-26 16:02:50 +03:00
testFrameworks := Nil,
scalacOptions ++= Seq("-Ypatmat-exhaust-depth", "off"),
2019-09-12 17:47:25 +03:00
mainClass in (Compile, run) := Some("org.enso.syntax.text.Main"),
version := "0.1",
logBuffered := false,
2019-11-26 16:02:50 +03:00
libraryDependencies ++= Seq(
2020-04-30 22:30:55 +03:00
"org.scalatest" %%% "scalatest" % scalatestVersion % Test,
"com.lihaoyi" %%% "pprint" % pprintVersion,
2019-11-26 16:02:50 +03:00
"io.circe" %%% "circe-core" % circeVersion,
"io.circe" %%% "circe-generic" % circeVersion,
"io.circe" %%% "circe-parser" % circeVersion
2019-09-12 17:47:25 +03:00
),
compile := (Compile / compile)
2019-09-12 17:47:25 +03:00
.dependsOn(Def.taskDyn {
val parserCompile =
(`syntax-definition`.jvm / Compile / compileIncremental).value
2019-09-12 17:47:25 +03:00
if (parserCompile.hasModified) {
Def.task {
streams.value.log.info("Parser changed, forcing recompilation.")
clean.value
}
} else Def.task {}
})
.value
)
2019-11-26 16:02:50 +03:00
.jvmSettings(
inConfig(Benchmark)(Defaults.testSettings),
unmanagedSourceDirectories in Benchmark +=
2020-03-27 18:45:31 +03:00
baseDirectory.value.getParentFile / "shared/src/bench/scala",
2020-04-30 22:30:55 +03:00
libraryDependencies +=
"com.storm-enroute" %% "scalameter" % scalameterVersion % "bench",
2019-11-26 16:02:50 +03:00
testFrameworks := List(
new TestFramework("org.scalatest.tools.Framework"),
new TestFramework("org.scalameter.ScalaMeterFramework")
),
bench := (test in Benchmark).tag(Exclusive).value
)
.jsSettings(
scalaJSUseMainModuleInitializer := false,
scalaJSLinkerConfig ~= { _.withModuleKind(ModuleKind.ESModule) },
testFrameworks := List(new TestFramework("org.scalatest.tools.Framework")),
Compile / fullOptJS / artifactPath := file("target/scala-parser.js")
2019-11-26 16:02:50 +03:00
)
lazy val `parser-service` = (project in file("lib/parser-service"))
2019-11-26 16:02:50 +03:00
.dependsOn(syntax.jvm)
.settings(
libraryDependencies ++= akka,
mainClass := Some("org.enso.ParserServiceMain")
)
lazy val `text-buffer` = project
.in(file("lib/text-buffer"))
.configs(Test)
.settings(
libraryDependencies ++= Seq(
"org.typelevel" %% "cats-core" % catsVersion,
2020-04-30 22:30:55 +03:00
"org.scalatest" %% "scalatest" % scalatestVersion % Test,
"org.scalacheck" %% "scalacheck" % scalacheckVersion % Test
)
)
lazy val graph = (project in file("lib/graph/"))
2019-11-26 16:02:50 +03:00
.dependsOn(logger.jvm)
.configs(Test)
.settings(
version := "0.1",
resolvers ++= Seq(
Resolver.sonatypeRepo("releases"),
Resolver.sonatypeRepo("snapshots")
),
2020-02-13 17:33:39 +03:00
scalacOptions += "-Ymacro-annotations",
2020-04-30 22:30:55 +03:00
libraryDependencies ++= scalaCompiler ++ Seq(
"com.chuusai" %% "shapeless" % shapelessVersion,
"io.estatico" %% "newtype" % newtypeVersion,
"org.scalatest" %% "scalatest" % scalatestVersion % Test,
"org.scalacheck" %% "scalacheck" % scalacheckVersion % Test,
"com.github.julien-truffaut" %% "monocle-core" % monocleVersion,
"org.apache.commons" % "commons-lang3" % commonsLangVersion
2019-11-26 16:02:50 +03:00
),
2020-04-30 22:30:55 +03:00
addCompilerPlugin(
"org.typelevel" %% "kind-projector" % kindProjectorVersion cross CrossVersion.full
2019-11-26 16:02:50 +03:00
),
addCompilerPlugin(
2020-04-30 22:30:55 +03:00
"io.tryp" % "splain" % splainVersion cross CrossVersion.patch
),
2020-04-30 22:30:55 +03:00
scalacOptions ++= splainOptions
2019-11-26 16:02:50 +03:00
)
lazy val pkg = (project in file("lib/pkg"))
.settings(
mainClass in (Compile, run) := Some("org.enso.pkg.Main"),
2019-09-12 17:47:25 +03:00
version := "0.1",
libraryDependencies ++= circe ++ Seq(
2020-04-30 22:30:55 +03:00
"io.circe" %% "circe-yaml" % circeYamlVersion, // separate from other circe deps because its independent project with its own versioning
"commons-io" % "commons-io" % commonsIoVersion
)
)
lazy val `project-manager` = (project in file("lib/project-manager"))
2019-11-18 14:18:16 +03:00
.settings(
(Compile / mainClass) := Some("org.enso.projectmanager.boot.ProjectManager")
2019-11-18 14:18:16 +03:00
)
.settings(
(Compile / run / fork) := true,
(Test / fork) := true,
(Compile / run / connectInput) := true,
javaOptions ++= {
// Note [Classpath Separation]
val runtimeClasspath =
(runtime / Compile / fullClasspath).value
.map(_.data)
.mkString(File.pathSeparator)
Seq(s"-Dtruffle.class.path.append=$runtimeClasspath")
},
2019-11-18 14:18:16 +03:00
libraryDependencies ++= akka,
2020-03-18 13:41:55 +03:00
libraryDependencies ++= circe,
libraryDependencies ++= Seq(
2020-04-30 22:30:55 +03:00
"com.typesafe" % "config" % typesafeConfigVersion,
"com.github.pureconfig" %% "pureconfig" % pureconfigVersion,
"ch.qos.logback" % "logback-classic" % logbackClassicVersion,
"com.typesafe.scala-logging" %% "scala-logging" % scalaLoggingVersion,
"dev.zio" %% "zio" % zioVersion,
"dev.zio" %% "zio-interop-cats" % zioInteropCatsVersion,
"commons-io" % "commons-io" % commonsIoVersion,
"com.beachape" %% "enumeratum-circe" % enumeratumCirceVersion,
"com.miguno.akka" %% "akka-mock-scheduler" % akkaMockSchedulerVersion % Test,
"org.mockito" %% "mockito-scala" % mockitoScalaVersion % Test
),
addCompilerPlugin(
2020-04-30 22:30:55 +03:00
"org.typelevel" %% "kind-projector" % kindProjectorVersion cross CrossVersion.full
2020-03-18 13:41:55 +03:00
)
2019-11-18 14:18:16 +03:00
)
2020-05-15 14:05:44 +03:00
.settings(
assemblyJarName in assembly := "project-manager.jar",
test in assembly := {},
assemblyOutputPath in assembly := file("project-manager.jar"),
assemblyMergeStrategy in assembly := {
case PathList("META-INF", file, xs @ _*) if file.endsWith(".DSA") =>
MergeStrategy.discard
case PathList("META-INF", file, xs @ _*) if file.endsWith(".SF") =>
MergeStrategy.discard
case PathList("META-INF", "MANIFEST.MF", xs @ _*) =>
MergeStrategy.discard
case "application.conf" => MergeStrategy.concat
case "reference.conf" => MergeStrategy.concat
case _ => MergeStrategy.first
},
assemblyOption in assembly := (assemblyOption in assembly).value
.copy(
prependShellScript = Some(
defaultUniversalScript(
shebang = false,
javaOpts = Seq("-Dtruffle.class.path.append=runtime.jar")
)
)
),
assembly := assembly
.dependsOn(runtime / assembly)
.value
2020-05-15 14:05:44 +03:00
)
2019-11-18 14:18:16 +03:00
.dependsOn(pkg)
.dependsOn(`language-server`)
2020-03-18 13:41:55 +03:00
.dependsOn(`json-rpc-server`)
.dependsOn(`json-rpc-server-test` % Test)
2019-11-18 14:18:16 +03:00
/* Note [Classpath Separation]
* ~~~~~~~~~~~~~~~~~~~~~~~~~~
* Projects using the language runtime do not depend on it directly, but instead
* the language runtime is put on the Truffle classpath, rather than the
* standard classpath. This is the recommended way of handling this and we
* strive to use such structure everywhere.
* See
* https://www.graalvm.org/docs/graalvm-as-a-platform/implement-language#graalvm
*
* Currently the only exception to this are the tests of the runtime project
* which have classpath separation disabled, because they need direct access to
* the runtime's instruments.
*
* To ensure correct handling of dependencies by sbt, the classpath appended to
* Java options, should be based on `(runtime / Compile / fullClasspath).value`
* wherever possible. Using a key from the runtime project enables sbt to see
* the dependency.
*
* Assembly tasks that build JAR files which need `runtime.jar` to run should
* also add a dependency on `runtime / assembly`.
*/
lazy val `json-rpc-server` = project
.in(file("lib/json-rpc-server"))
.settings(
libraryDependencies ++= akka,
libraryDependencies ++= circe,
libraryDependencies ++= Seq(
"io.circe" %% "circe-literal" % circeVersion,
akkaTestkit % Test,
2020-04-30 22:30:55 +03:00
"org.scalatest" %% "scalatest" % scalatestVersion % Test
)
)
2019-11-05 17:12:33 +03:00
lazy val `json-rpc-server-test` = project
.in(file("lib/json-rpc-server-test"))
.settings(
libraryDependencies ++= akka,
libraryDependencies ++= circe,
libraryDependencies ++= Seq(
"io.circe" %% "circe-literal" % circeVersion,
akkaTestkit,
2020-04-30 22:30:55 +03:00
"org.scalatest" %% "scalatest" % scalatestVersion
)
)
.dependsOn(`json-rpc-server`)
lazy val `core-definition` = (project in file("lib/core-definition"))
.configs(Benchmark)
.settings(
version := "0.1",
inConfig(Compile)(truffleRunOptionsSettings),
inConfig(Benchmark)(Defaults.testSettings),
parallelExecution in Test := false,
logBuffered in Test := false,
2020-02-13 17:33:39 +03:00
scalacOptions += "-Ymacro-annotations",
libraryDependencies ++= jmh ++ Seq(
2020-04-30 22:30:55 +03:00
"com.chuusai" %% "shapeless" % shapelessVersion,
"org.scalacheck" %% "scalacheck" % scalacheckVersion % Test,
"org.scalactic" %% "scalactic" % scalacticVersion % Test,
"org.scalatest" %% "scalatest" % scalatestVersion % Test,
2020-02-13 17:33:39 +03:00
"org.typelevel" %% "cats-core" % catsVersion,
2020-04-30 22:30:55 +03:00
"com.github.julien-truffaut" %% "monocle-core" % monocleVersion
),
addCompilerPlugin(
2020-04-30 22:30:55 +03:00
"org.typelevel" %% "kind-projector" % kindProjectorVersion cross CrossVersion.full
),
2020-04-30 22:30:55 +03:00
addCompilerPlugin(
"io.tryp" % "splain" % splainVersion cross CrossVersion.patch
),
scalacOptions ++= splainOptions
2020-02-13 17:33:39 +03:00
)
.dependsOn(graph)
.dependsOn(syntax.jvm)
lazy val searcher = project
.in(file("lib/searcher"))
.configs(Test)
.settings(
libraryDependencies ++= Seq(
"com.typesafe.slick" %% "slick" % "3.3.2",
"org.xerial" % "sqlite-jdbc" % "3.31.1",
"org.scalatest" %% "scalatest" % scalatestVersion % Test,
)
)
2020-04-30 22:30:55 +03:00
// ============================================================================
// === Sub-Projects ===========================================================
// ============================================================================
val truffleRunOptions = Seq(
"-Dpolyglot.engine.IterativePartialEscape=true",
"-Dpolyglot.engine.BackgroundCompilation=false"
)
val truffleRunOptionsSettings = Seq(
fork := true,
javaOptions ++= truffleRunOptions
)
lazy val `polyglot-api` = project
2020-02-13 17:33:39 +03:00
.in(file("engine/polyglot-api"))
.settings(
Test / fork := true,
Test / javaOptions ++= {
// Note [Classpath Separation]
val runtimeClasspath =
(LocalProject("runtime") / Compile / fullClasspath).value
.map(_.data)
.mkString(File.pathSeparator)
Seq(s"-Dtruffle.class.path.append=$runtimeClasspath")
},
2020-02-13 17:33:39 +03:00
libraryDependencies ++= Seq(
"org.graalvm.sdk" % "polyglot-tck" % graalVersion % "provided",
"com.google.flatbuffers" % "flatbuffers-java" % flatbuffersVersion,
"org.scalatest" %% "scalatest" % scalatestVersion % Test,
"org.scalacheck" %% "scalacheck" % scalacheckVersion % Test
),
2020-04-30 22:30:55 +03:00
libraryDependencies ++= jackson,
addCompilerPlugin(
2020-04-30 22:30:55 +03:00
"org.typelevel" %% "kind-projector" % kindProjectorVersion cross CrossVersion.full
),
2020-04-30 22:30:55 +03:00
addCompilerPlugin(
"io.tryp" % "splain" % splainVersion cross CrossVersion.patch
),
scalacOptions ++= splainOptions,
GenerateFlatbuffers.flatcVersion := flatbuffersVersion,
sourceGenerators in Compile += GenerateFlatbuffers.task
)
2020-02-13 17:33:39 +03:00
.dependsOn(pkg)
.dependsOn(`text-buffer`)
2020-02-13 17:33:39 +03:00
lazy val `language-server` = (project in file("engine/language-server"))
2020-02-13 17:33:39 +03:00
.settings(
libraryDependencies ++= akka ++ circe ++ Seq(
2020-04-30 22:30:55 +03:00
"ch.qos.logback" % "logback-classic" % logbackClassicVersion,
"com.typesafe.scala-logging" %% "scala-logging" % scalaLoggingVersion,
"io.circe" %% "circe-generic-extras" % circeVersion,
"io.circe" %% "circe-literal" % circeVersion,
2020-04-30 22:30:55 +03:00
"org.bouncycastle" % "bcpkix-jdk15on" % bcpkixJdk15Version,
"dev.zio" %% "zio" % zioVersion,
"io.methvin" % "directory-watcher" % directoryWatcherVersion,
"com.beachape" %% "enumeratum-circe" % enumeratumCirceVersion,
"com.google.flatbuffers" % "flatbuffers-java" % flatbuffersVersion,
akkaTestkit % Test,
2020-04-30 22:30:55 +03:00
"commons-io" % "commons-io" % commonsIoVersion,
"org.scalatest" %% "scalatest" % scalatestVersion % Test,
"org.scalacheck" %% "scalacheck" % scalacheckVersion % Test,
"org.graalvm.sdk" % "polyglot-tck" % graalVersion % "provided"
2020-02-28 16:17:48 +03:00
),
testOptions in Test += Tests
2020-04-17 16:47:58 +03:00
.Argument(TestFrameworks.ScalaCheck, "-minSuccessfulTests", "1000"),
GenerateFlatbuffers.flatcVersion := flatbuffersVersion,
2020-04-17 16:47:58 +03:00
sourceGenerators in Compile += GenerateFlatbuffers.task
2020-02-28 16:17:48 +03:00
)
.configs(Benchmark)
.settings(
inConfig(Benchmark)(Defaults.testSettings),
bench := (test in Benchmark).value,
2020-04-30 22:30:55 +03:00
libraryDependencies += "com.storm-enroute" %% "scalameter" % scalameterVersion % "bench",
2020-02-28 16:17:48 +03:00
testFrameworks ++= List(
new TestFramework("org.scalameter.ScalaMeterFramework")
2020-02-13 17:33:39 +03:00
)
)
.dependsOn(`polyglot-api`)
2020-03-18 13:41:55 +03:00
.dependsOn(`json-rpc-server`)
.dependsOn(`json-rpc-server-test` % Test)
.dependsOn(`text-buffer`)
lazy val runtime = (project in file("engine/runtime"))
2019-11-19 18:16:58 +03:00
.configs(Benchmark)
.settings(
2020-05-15 11:07:58 +03:00
version := ensoVersion,
2019-09-12 17:47:25 +03:00
commands += WithDebugCommand.withDebug,
2019-11-05 17:12:33 +03:00
inConfig(Compile)(truffleRunOptionsSettings),
2019-11-19 18:16:58 +03:00
inConfig(Benchmark)(Defaults.testSettings),
2019-09-12 17:47:25 +03:00
parallelExecution in Test := false,
logBuffered in Test := false,
2020-02-13 17:33:39 +03:00
scalacOptions += "-Ymacro-annotations",
scalacOptions ++= Seq("-Ypatmat-exhaust-depth", "off"),
libraryDependencies ++= circe ++ jmh ++ Seq(
2020-04-30 22:30:55 +03:00
"com.chuusai" %% "shapeless" % shapelessVersion,
"org.apache.commons" % "commons-lang3" % commonsLangVersion,
"org.apache.tika" % "tika-core" % tikaVersion,
"org.graalvm.sdk" % "graal-sdk" % graalVersion % "provided",
"org.graalvm.sdk" % "polyglot-tck" % graalVersion % "provided",
"org.graalvm.truffle" % "truffle-api" % graalVersion % "provided",
"org.graalvm.truffle" % "truffle-dsl-processor" % graalVersion % "provided",
"org.graalvm.truffle" % "truffle-tck" % graalVersion % "provided",
"org.graalvm.truffle" % "truffle-tck-common" % graalVersion % "provided",
2020-04-30 22:30:55 +03:00
"org.scalacheck" %% "scalacheck" % scalacheckVersion % Test,
"org.scalactic" %% "scalactic" % scalacticVersion % Test,
"org.scalatest" %% "scalatest" % scalatestVersion % Test,
"org.graalvm.truffle" % "truffle-api" % graalVersion % Benchmark,
2020-02-19 17:41:17 +03:00
"org.typelevel" %% "cats-core" % catsVersion,
2020-04-30 22:30:55 +03:00
"eu.timepit" %% "refined" % refinedVersion
),
// Note [Unmanaged Classpath]
Compile / unmanagedClasspath += (`core-definition` / Compile / packageBin).value,
Test / unmanagedClasspath += (`core-definition` / Compile / packageBin).value,
Compile / compile := FixInstrumentsGeneration.patchedCompile
.dependsOn(`core-definition` / Compile / packageBin)
.dependsOn(FixInstrumentsGeneration.preCompileTask)
.value,
// Note [Classpath Separation]
Test / javaOptions ++= Seq(
"-XX:-UseJVMCIClassLoader",
"-Dgraalvm.locatorDisabled=true"
)
)
.settings(
(Compile / javacOptions) ++= Seq(
"-s",
(Compile / sourceManaged).value.getAbsolutePath
2020-01-24 21:56:52 +03:00
),
addCompilerPlugin(
2020-04-30 22:30:55 +03:00
"org.typelevel" %% "kind-projector" % kindProjectorVersion cross CrossVersion.full
),
2020-04-30 22:30:55 +03:00
addCompilerPlugin(
"io.tryp" % "splain" % splainVersion cross CrossVersion.patch
),
scalacOptions ++= splainOptions
)
.settings(
(Compile / compile) := (Compile / compile)
.dependsOn(Def.task { (Compile / sourceManaged).value.mkdirs })
.value
)
.settings(
logBuffered := false,
2019-09-12 17:47:25 +03:00
bench := (test in Benchmark).tag(Exclusive).value,
benchOnly := Def.inputTaskDyn {
import complete.Parsers.spaceDelimited
val name = spaceDelimited("<name>").parsed match {
case List(name) => name
2019-08-28 18:40:08 +03:00
case _ => throw new IllegalArgumentException("Expected one argument.")
}
Def.task {
(testOnly in Benchmark).toTask(" -- -z " + name).value
}
}.evaluated,
parallelExecution in Benchmark := false
)
2020-05-15 14:05:44 +03:00
.settings(
assemblyJarName in assembly := "runtime.jar",
test in assembly := {},
assemblyOutputPath in assembly := file("runtime.jar"),
assemblyMergeStrategy in assembly := {
case PathList("META-INF", file, xs @ _*) if file.endsWith(".DSA") =>
MergeStrategy.discard
case PathList("META-INF", file, xs @ _*) if file.endsWith(".SF") =>
MergeStrategy.discard
case PathList("META-INF", "MANIFEST.MF", xs @ _*) =>
MergeStrategy.discard
case _ => MergeStrategy.first
}
)
2019-09-05 19:01:51 +03:00
.dependsOn(pkg)
2019-11-26 16:02:50 +03:00
.dependsOn(syntax.jvm)
2020-01-24 21:56:52 +03:00
.dependsOn(graph)
.dependsOn(`polyglot-api`)
.dependsOn(`text-buffer`)
.dependsOn(`searcher`)
2019-11-18 16:36:03 +03:00
/* Note [Unmanaged Classpath]
* ~~~~~~~~~~~~~~~~~~~~~~~~~~
* As the definition of the core primitives in `core_definition` is achieved
* entirely using the graph macros, this means that the IDE experience for those
* using these primitives is very poor.
*
* To get around this, we want to treat the core definition as a .jar dependency
* to force the IDE to depend on bytecode for its diagnostics, rather than the
* source code (as this means it sees the macros expanded). A standard workflow
* with local publishing would not recompile the definition automatically on
* changes, so the `unmanagedClasspath` route allows us to get automatic
* recompilation but still convince the IDE that it is a .jar dependency.
*/
lazy val runner = project
.in(file("engine/runner"))
2019-11-18 16:36:03 +03:00
.settings(
javaOptions ++= {
// Note [Classpath Separation]
val runtimeClasspath =
(runtime / Compile / fullClasspath).value
.map(_.data)
.mkString(File.pathSeparator)
Seq(s"-Dtruffle.class.path.append=$runtimeClasspath")
},
mainClass in (Compile, run) := Some("org.enso.runner.Main"),
2019-11-18 16:36:03 +03:00
mainClass in assembly := (Compile / run / mainClass).value,
assemblyJarName in assembly := "enso.jar",
test in assembly := {},
assemblyOutputPath in assembly := file("enso.jar"),
2020-03-06 17:17:46 +03:00
assemblyMergeStrategy in assembly := {
case PathList("META-INF", file, xs @ _*) if file.endsWith(".DSA") =>
MergeStrategy.discard
case PathList("META-INF", file, xs @ _*) if file.endsWith(".SF") =>
MergeStrategy.discard
case PathList("META-INF", "MANIFEST.MF", xs @ _*) =>
MergeStrategy.discard
case "application.conf" =>
MergeStrategy.concat
case "reference.conf" =>
MergeStrategy.concat
case x =>
MergeStrategy.first
},
assemblyOption in assembly := (assemblyOption in assembly).value
.copy(
prependShellScript = Some(
defaultUniversalScript(
shebang = false,
javaOpts = truffleRunOptions ++
Seq("-Dtruffle.class.path.append=runtime.jar")
)
2019-11-18 16:36:03 +03:00
)
),
2020-03-06 16:40:29 +03:00
commands += WithDebugCommand.withDebug,
2019-11-18 16:36:03 +03:00
inConfig(Compile)(truffleRunOptionsSettings),
libraryDependencies ++= Seq(
"org.graalvm.sdk" % "polyglot-tck" % graalVersion % "provided",
2019-11-19 18:16:58 +03:00
"org.graalvm.truffle" % "truffle-api" % graalVersion % "provided",
2020-04-30 22:30:55 +03:00
"commons-cli" % "commons-cli" % commonsCliVersion,
"com.monovore" %% "decline" % declineVersion,
"io.github.spencerpark" % "jupyter-jvm-basekernel" % jupyterJvmBasekernelVersion,
"org.jline" % "jline" % jlineVersion,
"org.typelevel" %% "cats-core" % catsVersion
),
connectInput in run := true
2019-11-18 16:36:03 +03:00
)
.settings(
buildNativeImage := Def
.task {
val javaHome = System.getProperty("java.home")
val nativeImagePath = s"$javaHome/bin/native-image"
val classPath = (Runtime / fullClasspath).value.files.mkString(":")
val resourcesGlobOpt = "-H:IncludeResources=.*Main.enso$"
val cmd =
s"$nativeImagePath $resourcesGlobOpt --macro:truffle --no-fallback --initialize-at-build-time -cp $classPath ${(Compile / mainClass).value.get} enso"
cmd !
}
.dependsOn(Compile / compile)
.value
)
.settings(
Compile / sourceGenerators += Def.task {
val file = (Compile / sourceManaged).value / "buildinfo" / "Info.scala"
BuildInfo
.writeBuildInfoFile(file, ensoVersion, scalacVersion, graalVersion)
}.taskValue,
assembly := assembly
.dependsOn(runtime / assembly)
.value
)
2019-11-18 16:36:03 +03:00
.dependsOn(pkg)
.dependsOn(`language-server`)
.dependsOn(`polyglot-api`)