sbt/build.sbt

689 lines
25 KiB
Plaintext
Raw Normal View History

2014-12-18 05:38:10 +01:00
import Util._
2014-12-18 13:57:05 +01:00
import Dependencies._
2014-12-18 05:38:10 +01:00
import Sxr.sxr
import com.typesafe.tools.mima.core._, ProblemFilters._
2014-12-18 05:38:10 +01:00
2015-02-06 19:48:12 +01:00
// ThisBuild settings take lower precedence,
// but can be shared across the multi projects.
2017-04-21 09:14:31 +02:00
def buildLevelSettings: Seq[Setting[_]] =
inThisBuild(
Seq(
organization := "org.scala-sbt",
2017-09-16 21:51:46 +02:00
version := "1.0.3-SNAPSHOT",
2017-04-21 09:14:31 +02:00
description := "sbt is an interactive build tool",
bintrayOrganization := Some("sbt"),
bintrayRepository := {
if (publishStatus.value == "releases") "maven-releases"
else "maven-snapshots"
},
bintrayPackage := "sbt",
bintrayReleaseOnPublish := false,
licenses := List("BSD New" -> url("https://github.com/sbt/sbt/blob/0.13/LICENSE")),
developers := List(
Developer("harrah", "Mark Harrah", "@harrah", url("https://github.com/harrah")),
Developer("eed3si9n", "Eugene Yokota", "@eed3si9n", url("https://github.com/eed3si9n")),
Developer("jsuereth", "Josh Suereth", "@jsuereth", url("https://github.com/jsuereth")),
Developer("dwijnand", "Dale Wijnand", "@dwijnand", url("https://github.com/dwijnand")),
Developer("gkossakowski",
"Grzegorz Kossakowski",
"@gkossakowski",
url("https://github.com/gkossakowski")),
Developer("Duhemm", "Martin Duhem", "@Duhemm", url("https://github.com/Duhemm"))
),
homepage := Some(url("https://github.com/sbt/sbt")),
scmInfo := Some(ScmInfo(url("https://github.com/sbt/sbt"), "git@github.com:sbt/sbt.git")),
2017-06-16 22:11:33 +02:00
resolvers += Resolver.mavenLocal,
scalafmtOnCompile := true,
2017-10-24 13:23:37 +02:00
scalafmtVersion := "1.3.0",
2017-04-21 09:14:31 +02:00
))
def commonSettings: Seq[Setting[_]] =
Seq[SettingsDefinition](
2017-10-04 19:01:06 +02:00
headerLicense := Some(HeaderLicense.Custom(
"""|sbt
|Copyright 2011 - 2017, Lightbend, Inc.
|Copyright 2008 - 2010, Mark Harrah
|Licensed under BSD-3-Clause license (see LICENSE)
|""".stripMargin
)),
2017-04-21 09:14:31 +02:00
scalaVersion := baseScalaVersion,
componentID := None,
resolvers += Resolver.typesafeIvyRepo("releases"),
resolvers += Resolver.sonatypeRepo("snapshots"),
resolvers += "bintray-sbt-maven-releases" at "https://dl.bintray.com/sbt/maven-releases/",
2017-10-19 02:10:01 +02:00
addCompilerPlugin("org.spire-math" % "kind-projector" % "0.9.4" cross CrossVersion.binary),
2017-04-21 09:14:31 +02:00
concurrentRestrictions in Global += Util.testExclusiveRestriction,
Unified slash syntax Fixes sbt/sbt#1812 This adds unified slash syntax for both sbt shell and the build.sbt DSL. Instead of the current `<project-id>/config:intask::key`, this adds `<project-id>/<config-ident>/intask/key` where <config-ident> is the Scala identifier notation for the configurations like `Compile` and `Test`. This also adds a series of implicits called `SlashSyntax` that adds `/` operators to project refererences, configuration, and keys such that the same syntax works in build.sbt. These examples work for both from the shell and in build.sbt. Global / cancelable ThisBuild / scalaVersion Test / test root / Compile / compile / scalacOptions ProjectRef(uri("file:/xxx/helloworld/"),"root")/Compile/scalacOptions Zero / Zero / name The inspect command now outputs something that can be copy-pasted: > inspect compile [info] Task: sbt.inc.Analysis [info] Description: [info] Compiles sources. [info] Provided by: [info] ProjectRef(uri("file:/xxx/helloworld/"),"root")/Compile/compile [info] Defined at: [info] (sbt.Defaults) Defaults.scala:326 [info] Dependencies: [info] Compile/manipulateBytecode [info] Compile/incCompileSetup [info] Reverse dependencies: [info] Compile/printWarnings [info] Compile/products [info] Compile/discoveredSbtPlugins [info] Compile/discoveredMainClasses [info] Delegates: [info] Compile/compile [info] compile [info] ThisBuild/Compile/compile [info] ThisBuild/compile [info] Zero/Compile/compile [info] Global/compile [info] Related: [info] Test/compile
2017-09-27 08:21:56 +02:00
testOptions in Test += Tests.Argument(TestFrameworks.ScalaCheck, "-w", "1"),
testOptions in Test += Tests.Argument(TestFrameworks.ScalaCheck, "-verbosity", "2"),
javacOptions in compile ++= Seq("-Xlint", "-Xlint:-serial"),
2017-04-21 09:14:31 +02:00
crossScalaVersions := Seq(baseScalaVersion),
bintrayPackage := (bintrayPackage in ThisBuild).value,
bintrayRepository := (bintrayRepository in ThisBuild).value,
publishArtifact in Test := false,
fork in compile := true,
fork in run := true
2017-04-21 09:14:31 +02:00
) flatMap (_.settings)
2014-12-18 05:38:10 +01:00
def minimalSettings: Seq[Setting[_]] =
commonSettings ++ customCommands ++
2017-04-21 09:14:31 +02:00
publishPomSettings ++ Release.javaVersionCheckSettings
2014-12-18 05:38:10 +01:00
def baseSettings: Seq[Setting[_]] =
2017-04-20 01:56:35 +02:00
minimalSettings ++ Seq(projectComponent) ++ baseScalacOptions ++ Licensed.settings
2014-12-18 05:38:10 +01:00
def testedBaseSettings: Seq[Setting[_]] =
baseSettings ++ testDependencies
2017-07-20 18:31:39 +02:00
val mimaSettings = Def settings (
2017-12-05 08:27:32 +01:00
mimaPreviousArtifacts := (0 to 4).map { v =>
organization.value % moduleName.value % s"1.0.$v" cross (if (crossPaths.value) CrossVersion.binary else CrossVersion.disabled)
}.toSet
2017-07-20 18:31:39 +02:00
)
2017-04-21 09:14:31 +02:00
lazy val sbtRoot: Project = (project in file("."))
Upgrade the build to sbt 1.0.0-M5 Some plugins remain commented out, for now. sbt-doge is no longer needed because a variant of it has been folded into sbt 1. For some reason scripted requires src/doc jars of sbt, so switch back to using `publishAll` rather than `publishLocalBinAll`. :( Also, the sys.prop change in scripted is to force log4j2 to not use a thread context classloader, and avoid the following: ERROR StatusLogger Unable to create custom ContextSelector. Falling back to default. java.lang.ClassCastException: Cannot cast org.apache.logging.log4j.core.async.AsyncLoggerContextSelector to org.apache.logging.log4j.core.selector.ContextSelector at java.lang.Class.cast(Class.java:3369) at org.apache.logging.log4j.util.LoaderUtil.newCheckedInstanceOf(LoaderUtil.java:201) at org.apache.logging.log4j.util.LoaderUtil.newCheckedInstanceOfProperty(LoaderUtil.java:226) at org.apache.logging.log4j.core.impl.Log4jContextFactory.createContextSelector(Log4jContextFactory.java:97) at org.apache.logging.log4j.core.impl.Log4jContextFactory.<init>(Log4jContextFactory.java:58) at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.lang.reflect.Constructor.newInstance(Constructor.java:423) at java.lang.Class.newInstance(Class.java:442) at org.apache.logging.log4j.LogManager.<clinit>(LogManager.java:94) at org.apache.logging.log4j.spi.ThreadContextMapFactory.createThreadContextMap(ThreadContextMapFactory.java:73) at org.apache.logging.log4j.ThreadContext.init(ThreadContext.java:223) at org.apache.logging.log4j.ThreadContext.<clinit>(ThreadContext.java:202) at org.apache.logging.log4j.core.impl.ContextDataInjectorFactory.createDefaultInjector(ContextDataInjectorFactory.java:83) at org.apache.logging.log4j.core.impl.ContextDataInjectorFactory.createInjector(ContextDataInjectorFactory.java:67) at org.apache.logging.log4j.core.lookup.ContextMapLookup.<init>(ContextMapLookup.java:34) at org.apache.logging.log4j.core.lookup.Interpolator.<init>(Interpolator.java:117) at org.apache.logging.log4j.core.config.AbstractConfiguration.<init>(AbstractConfiguration.java:125) at org.apache.logging.log4j.core.config.DefaultConfiguration.<init>(DefaultConfiguration.java:46) at org.apache.logging.log4j.core.layout.PatternLayout$Builder.build(PatternLayout.java:650) at org.apache.logging.log4j.core.layout.PatternLayout.createDefaultLayout(PatternLayout.java:487) at sbt.internal.util.ConsoleAppender.<init>(ConsoleAppender.scala:245) at sbt.internal.util.ConsoleAppender$.apply(ConsoleAppender.scala:196) at sbt.internal.util.ConsoleLogger.<init>(ConsoleAppender.scala:42) at sbt.internal.util.ConsoleLogger$.apply(ConsoleAppender.scala:34) at sbt.test.ScriptedRunner.run(ScriptedTests.scala:221) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at Scripted$.doScripted(Scripted.scala:125) at $0483e89d182e9d240274$.$anonfun$scriptedTask$5(build.sbt:301)
2017-05-03 16:52:36 +02:00
.enablePlugins(ScriptedPlugin) // , SiteScaladocPlugin, GhpagesPlugin)
2017-07-20 04:00:42 +02:00
.configs(Sxr.SxrConf)
.aggregate(nonRoots: _*)
2017-04-21 09:14:31 +02:00
.settings(
buildLevelSettings,
minimalSettings,
2017-05-08 15:34:41 +02:00
Util.baseScalacOptions,
Docs.settings,
Sxr.settings,
scalacOptions += "-Ymacro-expand:none", // for both sxr and doc
sources in sxr := {
val allSources = (sources ?? Nil).all(docProjects).value
allSources.flatten.distinct
}, //sxr
sources in (Compile, doc) := (sources in sxr).value, // doc
Sxr.sourceDirectories := {
val allSourceDirectories = (sourceDirectories ?? Nil).all(docProjects).value
allSourceDirectories.flatten
},
fullClasspath in sxr := (externalDependencyClasspath in Compile in sbtProj).value,
dependencyClasspath in (Compile, doc) := (fullClasspath in sxr).value,
Util.publishPomSettings,
otherRootSettings,
Transform.conscriptSettings(bundledLauncherProj),
publish := {},
2017-05-30 08:44:13 +02:00
publishLocal := {},
2017-11-29 22:45:02 +01:00
skip in publish := true,
commands in Global += Command.single("sbtOn")((state, dir) =>
s"sbtProj/test:runMain sbt.RunFromSourceMain $dir" :: state),
)
// This is used to configure an sbt-launcher for this version of sbt.
lazy val bundledLauncherProj =
2017-04-21 09:14:31 +02:00
(project in file("launch"))
.settings(
minimalSettings,
inConfig(Compile)(Transform.configSettings),
Release.launcherSettings(sbtLaunchJar)
)
.enablePlugins(SbtLauncherPlugin)
.settings(
name := "sbt-launch",
moduleName := "sbt-launch",
description := "sbt application launcher",
autoScalaLibrary := false,
crossPaths := false,
2017-07-20 18:31:39 +02:00
// mimaSettings, // TODO: Configure MiMa, deal with Proguard
2017-04-21 09:14:31 +02:00
publish := Release.deployLauncher.value,
publishLauncher := Release.deployLauncher.value,
packageBin in Compile := sbtLaunchJar.value
)
2014-12-18 05:38:10 +01:00
/* ** subproject declarations ** */
2014-12-18 05:38:10 +01:00
val collectionProj = (project in file("internal") / "util-collection")
.settings(
testedBaseSettings,
Util.keywordsSettings,
name := "Collections",
2017-07-20 18:31:39 +02:00
libraryDependencies ++= Seq(sjsonNewScalaJson.value),
mimaSettings,
2017-09-22 05:05:48 +02:00
mimaBinaryIssueFilters ++= Seq(
// Added private[sbt] method to capture State attributes.
exclude[ReversedMissingMethodProblem]("sbt.internal.util.AttributeMap.setCond"),
2017-10-20 05:18:43 +02:00
2017-10-19 02:10:29 +02:00
// Dropped in favour of kind-projector's inline type lambda syntax
exclude[MissingClassProblem]("sbt.internal.util.TypeFunctions$P1of2"),
2017-10-20 00:19:16 +02:00
// Dropped in favour of kind-projector's polymorphic lambda literals
exclude[MissingClassProblem]("sbt.internal.util.Param"),
exclude[MissingClassProblem]("sbt.internal.util.Param$"),
2017-10-20 05:18:43 +02:00
// Dropped in favour of plain scala.Function, and its compose method
exclude[MissingClassProblem]("sbt.internal.util.Fn1"),
exclude[DirectMissingMethodProblem]("sbt.internal.util.TypeFunctions.toFn1"),
exclude[DirectMissingMethodProblem]("sbt.internal.util.Types.toFn1"),
// Instead of defining foldr in KList & overriding in KCons,
// it's now abstract in KList and defined in both KCons & KNil.
exclude[FinalMethodProblem]("sbt.internal.util.KNil.foldr"),
exclude[DirectAbstractMethodProblem]("sbt.internal.util.KList.foldr"),
2017-09-22 05:05:48 +02:00
),
)
.configure(addSbtUtilPosition)
// Command line-related utilities.
val completeProj = (project in file("internal") / "util-complete")
.dependsOn(collectionProj)
.settings(
testedBaseSettings,
name := "Completion",
2017-07-20 18:31:39 +02:00
libraryDependencies += jline,
mimaSettings,
)
.configure(addSbtIO, addSbtUtilControl)
// A logic with restricted negation as failure for a unique, stable model
val logicProj = (project in file("internal") / "util-logic")
.dependsOn(collectionProj)
.settings(
testedBaseSettings,
2017-07-20 18:31:39 +02:00
name := "Logic",
mimaSettings,
)
.configure(addSbtUtilRelation)
2014-12-18 05:38:10 +01:00
/* **** Intermediate-level Modules **** */
// Runner for uniform test interface
2017-04-21 09:14:31 +02:00
lazy val testingProj = (project in file("testing"))
.enablePlugins(ContrabandPlugin, JsonCodecPlugin)
.dependsOn(testAgentProj)
.settings(
baseSettings,
2014-12-18 05:38:10 +01:00
name := "Testing",
libraryDependencies ++= Seq(testInterface, launcherInterface, sjsonNewScalaJson.value),
managedSourceDirectories in Compile +=
baseDirectory.value / "src" / "main" / "contraband-scala",
2017-04-01 23:19:45 +02:00
sourceManaged in (Compile, generateContrabands) := baseDirectory.value / "src" / "main" / "contraband-scala",
2017-07-20 18:31:39 +02:00
contrabandFormatsForType in generateContrabands in Compile := ContrabandConfig.getFormats,
mimaSettings,
2017-04-21 09:14:31 +02:00
)
.configure(addSbtIO, addSbtCompilerClasspath, addSbtUtilLogging)
2014-12-18 05:38:10 +01:00
// Testing agent for running tests in a separate process.
Replace previous scalafmt plugin by neo-scalafmt The previous scalafmt plugin had two problems: * Caching with Coursier did not work correctly * It failed after the upgrade to 1.0 in my computer (from a clean fork): ``` [error] (testingProj/compile:scalafmtInc) java.lang.NoClassDefFoundError: Could not initialize class scala.meta.package$ [error] (runProj/compile:scalafmtInc) java.lang.NoClassDefFoundError: Could not initialize class scala.meta.package$ [error] (taskProj/compile:scalafmtInc) java.lang.NoClassDefFoundError: Could not initialize class scala.meta.package$ [error] (stdTaskProj/compile:scalafmtInc) java.lang.NoClassDefFoundError: Could not initialize class scala.meta.package$ [error] (actionsProj/compile:scalafmtInc) java.lang.NoClassDefFoundError: Could not initialize class scala.meta.package$ [error] (protocolProj/compile:scalafmtInc) java.lang.NoClassDefFoundError: Could not initialize class scala.meta.package$ [error] (commandProj/compile:scalafmtInc) java.lang.NoClassDefFoundError: Could not initialize class scala.meta.package$ [error] (mainSettingsProj/compile:scalafmtInc) java.lang.NoClassDefFoundError: Could not initialize class scala.meta.package$ [error] (mainProj/compile:scalafmtInc) java.lang.NoClassDefFoundError: Could not initialize class scala.meta.package$ [error] (sbtProj/compile:scalafmtInc) java.lang.NoClassDefFoundError: Could not initialize class scala.meta.package$ [error] (scriptedPluginProj/compile:scalafmtInc) java.lang.NoClassDefFoundError: Could not initialize class scala.meta.package$ [error] (scriptedSbtProj/compile:scalafmtInc) java.lang.NoClassDefFoundError: Could not initialize class scala.meta.package$ [error] Total time: 19 s, completed May 24, 2017 10:44:56 AM ``` This commit replaces the previous scalafmt integration by the one created by Lucidsoftware, big shoutout! (/cc @pauldraper) https://github.com/lucidsoftware/neo-sbt-scalafmt
2017-05-24 11:15:22 +02:00
lazy val testAgentProj = (project in file("testing") / "agent")
.settings(
minimalSettings,
crossScalaVersions := Seq(baseScalaVersion),
crossPaths := false,
autoScalaLibrary := false,
name := "Test Agent",
2017-07-20 18:31:39 +02:00
libraryDependencies += testInterface,
mimaSettings,
Replace previous scalafmt plugin by neo-scalafmt The previous scalafmt plugin had two problems: * Caching with Coursier did not work correctly * It failed after the upgrade to 1.0 in my computer (from a clean fork): ``` [error] (testingProj/compile:scalafmtInc) java.lang.NoClassDefFoundError: Could not initialize class scala.meta.package$ [error] (runProj/compile:scalafmtInc) java.lang.NoClassDefFoundError: Could not initialize class scala.meta.package$ [error] (taskProj/compile:scalafmtInc) java.lang.NoClassDefFoundError: Could not initialize class scala.meta.package$ [error] (stdTaskProj/compile:scalafmtInc) java.lang.NoClassDefFoundError: Could not initialize class scala.meta.package$ [error] (actionsProj/compile:scalafmtInc) java.lang.NoClassDefFoundError: Could not initialize class scala.meta.package$ [error] (protocolProj/compile:scalafmtInc) java.lang.NoClassDefFoundError: Could not initialize class scala.meta.package$ [error] (commandProj/compile:scalafmtInc) java.lang.NoClassDefFoundError: Could not initialize class scala.meta.package$ [error] (mainSettingsProj/compile:scalafmtInc) java.lang.NoClassDefFoundError: Could not initialize class scala.meta.package$ [error] (mainProj/compile:scalafmtInc) java.lang.NoClassDefFoundError: Could not initialize class scala.meta.package$ [error] (sbtProj/compile:scalafmtInc) java.lang.NoClassDefFoundError: Could not initialize class scala.meta.package$ [error] (scriptedPluginProj/compile:scalafmtInc) java.lang.NoClassDefFoundError: Could not initialize class scala.meta.package$ [error] (scriptedSbtProj/compile:scalafmtInc) java.lang.NoClassDefFoundError: Could not initialize class scala.meta.package$ [error] Total time: 19 s, completed May 24, 2017 10:44:56 AM ``` This commit replaces the previous scalafmt integration by the one created by Lucidsoftware, big shoutout! (/cc @pauldraper) https://github.com/lucidsoftware/neo-sbt-scalafmt
2017-05-24 11:15:22 +02:00
)
2014-12-18 05:38:10 +01:00
// Basic task engine
2017-04-21 09:14:31 +02:00
lazy val taskProj = (project in file("tasks"))
.dependsOn(collectionProj)
2017-04-21 09:14:31 +02:00
.settings(
testedBaseSettings,
2017-07-20 18:31:39 +02:00
name := "Tasks",
mimaSettings,
2017-04-21 09:14:31 +02:00
)
.configure(addSbtUtilControl)
2014-12-18 05:38:10 +01:00
// Standard task system. This provides map, flatMap, join, and more on top of the basic task model.
2017-04-21 09:14:31 +02:00
lazy val stdTaskProj = (project in file("tasks-standard"))
.dependsOn(collectionProj)
2017-04-21 09:14:31 +02:00
.dependsOn(taskProj % "compile;test->test")
.settings(
testedBaseSettings,
2014-12-18 05:38:10 +01:00
name := "Task System",
2017-07-20 18:31:39 +02:00
testExclusive,
mimaSettings,
2017-04-21 09:14:31 +02:00
)
.configure(addSbtIO, addSbtUtilLogging, addSbtUtilCache)
2014-12-18 05:38:10 +01:00
// Embedded Scala code runner
2017-04-21 09:14:31 +02:00
lazy val runProj = (project in file("run"))
2017-06-16 22:11:33 +02:00
.enablePlugins(ContrabandPlugin)
.dependsOn(collectionProj)
2017-04-21 09:14:31 +02:00
.settings(
testedBaseSettings,
2017-05-12 00:33:12 +02:00
name := "Run",
managedSourceDirectories in Compile +=
baseDirectory.value / "src" / "main" / "contraband-scala",
2017-07-20 18:31:39 +02:00
sourceManaged in (Compile, generateContrabands) := baseDirectory.value / "src" / "main" / "contraband-scala",
mimaSettings,
2017-04-21 09:14:31 +02:00
)
.configure(addSbtIO, addSbtUtilLogging, addSbtCompilerClasspath)
2014-12-18 05:38:10 +01:00
2017-04-21 09:14:31 +02:00
lazy val scriptedSbtProj = (project in scriptedPath / "sbt")
.dependsOn(commandProj)
.settings(
baseSettings,
name := "Scripted sbt",
2017-07-20 18:31:39 +02:00
libraryDependencies ++= Seq(launcherInterface % "provided"),
mimaSettings,
2017-04-21 09:14:31 +02:00
)
.configure(addSbtIO, addSbtUtilLogging, addSbtCompilerInterface, addSbtUtilScripted, addSbtLmCore)
2014-12-18 05:38:10 +01:00
2017-04-21 09:14:31 +02:00
lazy val scriptedPluginProj = (project in scriptedPath / "plugin")
.dependsOn(sbtProj)
.settings(
baseSettings,
2017-07-20 18:31:39 +02:00
name := "Scripted Plugin",
mimaSettings,
2017-04-21 09:14:31 +02:00
)
.configure(addSbtCompilerClasspath)
2014-12-18 05:38:10 +01:00
// Implementation and support code for defining actions.
2017-04-21 09:14:31 +02:00
lazy val actionsProj = (project in file("main-actions"))
.dependsOn(completeProj, runProj, stdTaskProj, taskProj, testingProj)
2017-04-21 09:14:31 +02:00
.settings(
testedBaseSettings,
name := "Actions",
2017-07-20 18:31:39 +02:00
libraryDependencies += sjsonNewScalaJson.value,
mimaSettings,
2017-04-21 09:14:31 +02:00
)
.configure(
addSbtIO,
addSbtUtilLogging,
addSbtUtilRelation,
2017-07-16 00:09:40 +02:00
addSbtUtilTracking,
addSbtCompilerInterface,
addSbtCompilerClasspath,
addSbtCompilerApiInfo,
2017-07-16 00:09:40 +02:00
addSbtLmCore,
addSbtCompilerIvyIntegration,
addSbtZinc
2017-04-21 09:14:31 +02:00
)
lazy val protocolProj = (project in file("protocol"))
2017-06-16 22:11:33 +02:00
.enablePlugins(ContrabandPlugin, JsonCodecPlugin)
2017-04-21 09:14:31 +02:00
.settings(
2016-12-01 09:14:07 +01:00
testedBaseSettings,
name := "Protocol",
libraryDependencies ++= Seq(sjsonNewScalaJson.value),
managedSourceDirectories in Compile +=
baseDirectory.value / "src" / "main" / "contraband-scala",
sourceManaged in (Compile, generateContrabands) := baseDirectory.value / "src" / "main" / "contraband-scala",
2017-07-20 18:31:39 +02:00
contrabandFormatsForType in generateContrabands in Compile := ContrabandConfig.getFormats,
mimaSettings,
2017-04-21 09:14:31 +02:00
)
.configure(addSbtUtilLogging)
2016-12-01 09:14:07 +01:00
2014-12-18 05:38:10 +01:00
// General command support and core commands not specific to a build system
2017-04-21 09:14:31 +02:00
lazy val commandProj = (project in file("main-command"))
2017-06-16 22:11:33 +02:00
.enablePlugins(ContrabandPlugin, JsonCodecPlugin)
.dependsOn(protocolProj, completeProj)
2017-04-21 09:14:31 +02:00
.settings(
testedBaseSettings,
name := "Command",
libraryDependencies ++= Seq(launcherInterface, sjsonNewScalaJson.value, templateResolverApi,
jna, jnaPlatform),
managedSourceDirectories in Compile +=
baseDirectory.value / "src" / "main" / "contraband-scala",
sourceManaged in (Compile, generateContrabands) := baseDirectory.value / "src" / "main" / "contraband-scala",
2017-07-20 18:31:39 +02:00
contrabandFormatsForType in generateContrabands in Compile := ContrabandConfig.getFormats,
mimaSettings,
mimaBinaryIssueFilters ++= Vector(
// Changed the signature of Server method. nacho cheese.
2017-09-22 05:05:48 +02:00
exclude[DirectMissingMethodProblem]("sbt.internal.server.Server.*"),
// Added method to ServerInstance. This is also internal.
exclude[ReversedMissingMethodProblem]("sbt.internal.server.ServerInstance.*"),
2017-10-02 21:52:02 +02:00
// Added method to CommandChannel. internal.
exclude[ReversedMissingMethodProblem]("sbt.internal.CommandChannel.*"),
// Added an overload to reboot. The overload is private[sbt].
exclude[ReversedMissingMethodProblem]("sbt.StateOps.reboot"),
),
unmanagedSources in (Compile, headerCreate) := {
val old = (unmanagedSources in (Compile, headerCreate)).value
old filterNot { x => (x.getName startsWith "NG") || (x.getName == "ReferenceCountedFileDescriptor.java") }
},
2017-04-21 09:14:31 +02:00
)
2017-06-23 18:58:00 +02:00
.configure(
addSbtIO,
addSbtUtilLogging,
addSbtCompilerInterface,
2017-06-23 18:58:00 +02:00
addSbtCompilerClasspath,
2017-07-16 00:09:40 +02:00
addSbtLmCore
2017-06-23 18:58:00 +02:00
)
2014-12-18 05:38:10 +01:00
// The core macro project defines the main logic of the DSL, abstracted
// away from several sbt implementators (tasks, settings, et cetera).
2017-05-23 23:53:04 +02:00
lazy val coreMacrosProj = (project in file("core-macros"))
.dependsOn(collectionProj)
2017-05-23 23:53:04 +02:00
.settings(
commonSettings,
name := "Core Macros",
2017-07-20 18:31:39 +02:00
libraryDependencies += "org.scala-lang" % "scala-compiler" % scalaVersion.value,
mimaSettings,
)
/* Write all the compile-time dependencies of the spores macro to a file,
* in order to read it from the created Toolbox to run the neg tests. */
lazy val generateToolboxClasspath = Def.task {
val classpathAttributes = (dependencyClasspath in Compile).value
val dependenciesClasspath =
classpathAttributes.map(_.data.getAbsolutePath).mkString(":")
val scalaBinVersion = (scalaBinaryVersion in Compile).value
val targetDir = (target in Compile).value
val compiledClassesDir = targetDir / s"scala-$scalaBinVersion/classes"
val testClassesDir = targetDir / s"scala-$scalaBinVersion/test-classes"
val classpath = s"$compiledClassesDir:$testClassesDir:$dependenciesClasspath"
val resourceDir = (resourceDirectory in Compile).value
resourceDir.mkdir() // In case it doesn't exist
val toolboxTestClasspath = resourceDir / "toolbox.classpath"
IO.write(toolboxTestClasspath, classpath)
val result = List(toolboxTestClasspath.getAbsoluteFile)
streams.value.log.success("Wrote the classpath for the macro neg test suite.")
result
}
2014-12-18 05:38:10 +01:00
// Fixes scope=Scope for Setting (core defined in collectionProj) to define the settings system used in build definitions
2017-04-21 09:14:31 +02:00
lazy val mainSettingsProj = (project in file("main-settings"))
.dependsOn(completeProj, commandProj, stdTaskProj, coreMacrosProj)
2017-04-21 09:14:31 +02:00
.settings(
testedBaseSettings,
name := "Main Settings",
2017-07-20 18:31:39 +02:00
resourceGenerators in Compile += generateToolboxClasspath.taskValue,
mimaSettings,
2017-04-21 09:14:31 +02:00
)
.configure(
addSbtIO,
addSbtUtilLogging,
2017-04-21 09:14:31 +02:00
addSbtUtilCache,
addSbtUtilRelation,
addSbtCompilerInterface,
2017-04-21 09:14:31 +02:00
addSbtCompilerClasspath,
2017-07-16 00:09:40 +02:00
addSbtLmCore
2017-04-21 09:14:31 +02:00
)
2014-12-18 05:38:10 +01:00
2016-11-23 16:17:34 +01:00
// The main integration project for sbt. It brings all of the projects together, configures them, and provides for overriding conventions.
2017-04-21 09:14:31 +02:00
lazy val mainProj = (project in file("main"))
2017-06-16 22:11:33 +02:00
.enablePlugins(ContrabandPlugin)
.dependsOn(logicProj, actionsProj, mainSettingsProj, runProj, commandProj, collectionProj)
2017-04-21 09:14:31 +02:00
.settings(
testedBaseSettings,
2014-12-18 05:38:10 +01:00
name := "Main",
libraryDependencies ++= scalaXml.value ++ Seq(launcherInterface) ++ log4jDependencies ++ Seq(scalaCacheCaffeine),
managedSourceDirectories in Compile +=
baseDirectory.value / "src" / "main" / "contraband-scala",
2017-07-20 18:31:39 +02:00
sourceManaged in (Compile, generateContrabands) := baseDirectory.value / "src" / "main" / "contraband-scala",
mimaSettings,
2017-09-22 05:05:48 +02:00
mimaBinaryIssueFilters ++= Vector(
// Changed the signature of NetworkChannel ctor. internal.
exclude[DirectMissingMethodProblem]("sbt.internal.server.NetworkChannel.*"),
Unified slash syntax Fixes sbt/sbt#1812 This adds unified slash syntax for both sbt shell and the build.sbt DSL. Instead of the current `<project-id>/config:intask::key`, this adds `<project-id>/<config-ident>/intask/key` where <config-ident> is the Scala identifier notation for the configurations like `Compile` and `Test`. This also adds a series of implicits called `SlashSyntax` that adds `/` operators to project refererences, configuration, and keys such that the same syntax works in build.sbt. These examples work for both from the shell and in build.sbt. Global / cancelable ThisBuild / scalaVersion Test / test root / Compile / compile / scalacOptions ProjectRef(uri("file:/xxx/helloworld/"),"root")/Compile/scalacOptions Zero / Zero / name The inspect command now outputs something that can be copy-pasted: > inspect compile [info] Task: sbt.inc.Analysis [info] Description: [info] Compiles sources. [info] Provided by: [info] ProjectRef(uri("file:/xxx/helloworld/"),"root")/Compile/compile [info] Defined at: [info] (sbt.Defaults) Defaults.scala:326 [info] Dependencies: [info] Compile/manipulateBytecode [info] Compile/incCompileSetup [info] Reverse dependencies: [info] Compile/printWarnings [info] Compile/products [info] Compile/discoveredSbtPlugins [info] Compile/discoveredMainClasses [info] Delegates: [info] Compile/compile [info] compile [info] ThisBuild/Compile/compile [info] ThisBuild/compile [info] Zero/Compile/compile [info] Global/compile [info] Related: [info] Test/compile
2017-09-27 08:21:56 +02:00
// ctor for ConfigIndex. internal.
exclude[DirectMissingMethodProblem]("sbt.internal.ConfigIndex.*"),
// New and changed methods on KeyIndex. internal.
exclude[ReversedMissingMethodProblem]("sbt.internal.KeyIndex.*"),
exclude[DirectMissingMethodProblem]("sbt.internal.KeyIndex.*"),
2017-10-02 21:52:02 +02:00
// Removed unused val. internal.
exclude[DirectMissingMethodProblem]("sbt.internal.RelayAppender.jsonFormat"),
// Removed unused def. internal.
exclude[DirectMissingMethodProblem]("sbt.internal.Load.isProjectThis"),
2017-09-22 05:05:48 +02:00
)
2017-04-21 09:14:31 +02:00
)
2017-06-23 18:58:00 +02:00
.configure(
addSbtIO,
addSbtUtilLogging,
2017-07-16 00:09:40 +02:00
addSbtLmCore,
addSbtLmIvy,
addSbtCompilerInterface,
addSbtZincCompile
)
2014-12-18 05:38:10 +01:00
// Strictly for bringing implicits and aliases from subsystems into the top-level sbt namespace through a single package object
// technically, we need a dependency on all of mainProj's dependencies, but we don't do that since this is strictly an integration project
// with the sole purpose of providing certain identifiers without qualification (with a package object)
2017-04-21 09:14:31 +02:00
lazy val sbtProj = (project in file("sbt"))
.dependsOn(mainProj, scriptedSbtProj % "test->test")
.enablePlugins(BuildInfoPlugin)
2017-04-21 09:14:31 +02:00
.settings(
baseSettings,
2014-12-18 05:38:10 +01:00
name := "sbt",
2015-09-14 09:27:22 +02:00
normalizedName := "sbt",
crossScalaVersions := Seq(baseScalaVersion),
2017-07-20 18:31:39 +02:00
crossPaths := false,
javaOptions ++= Seq("-Xdebug", "-Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5005"),
2017-07-20 18:31:39 +02:00
mimaSettings,
mimaBinaryIssueFilters ++= sbtIgnoredProblems,
addBuildInfoToConfig(Test),
buildInfoObject in Test := "TestBuildInfo",
buildInfoKeys in Test := Seq[BuildInfoKey](fullClasspath in Compile),
connectInput in run in Test := true,
2017-04-21 09:14:31 +02:00
)
.configure(addSbtCompilerBridge)
2017-10-20 05:18:43 +02:00
lazy val sbtIgnoredProblems = {
2017-11-29 22:45:02 +01:00
Vector(
// Added more items to Import trait.
exclude[ReversedMissingMethodProblem]("sbt.Import.sbt$Import$_setter_$WatchSource_="),
2017-11-29 22:45:02 +01:00
exclude[ReversedMissingMethodProblem]("sbt.Import.WatchSource"),
2017-10-20 00:19:16 +02:00
2017-11-29 22:45:02 +01:00
// Dropped in favour of kind-projector's polymorphic lambda literals
exclude[DirectMissingMethodProblem]("sbt.Import.Param"),
exclude[DirectMissingMethodProblem]("sbt.package.Param"),
// Dropped in favour of plain scala.Function, and its compose method
exclude[DirectMissingMethodProblem]("sbt.package.toFn1"),
2017-04-21 09:14:31 +02:00
)
}
2014-12-18 05:38:10 +01:00
def runNpm(command: String, base: File, log: sbt.internal.util.ManagedLogger) = {
val npm = if (sbt.internal.util.Util.isWindows) "npm.cmd" else "npm"
import scala.sys.process._
try {
val exitCode = Process(s"$npm $command", Option(base)) ! log
if (exitCode != 0) throw new Exception("Process returned exit code: " + exitCode)
} catch {
case e: java.io.IOException => log.warn("failed to run npm " + e.getMessage)
}
}
lazy val vscodePlugin = (project in file("vscode-sbt-scala"))
.settings(
crossPaths := false,
crossScalaVersions := Seq(baseScalaVersion),
skip in publish := true,
compile in Compile := {
val u = update.value
runNpm("run compile", baseDirectory.value, streams.value.log)
sbt.internal.inc.Analysis.empty
},
update := {
val old = update.value
val t = target.value / "updated"
val base = baseDirectory.value
val log = streams.value.log
if (t.exists) ()
else {
runNpm("install", base, log)
IO.touch(t)
}
old
},
cleanFiles ++= {
val base = baseDirectory.value
Vector(
target.value / "updated",
base / "node_modules", base / "client" / "node_modules",
base / "client" / "server",
base / "client" / "out",
base / "server" / "node_modules") filter { _.exists }
}
)
2015-07-10 11:53:48 +02:00
def scriptedTask: Def.Initialize[InputTask[Unit]] = Def.inputTask {
val result = scriptedSource(dir => (s: State) => Scripted.scriptedParser(dir)).parsed
Upgrade the build to sbt 1.0.0-M5 Some plugins remain commented out, for now. sbt-doge is no longer needed because a variant of it has been folded into sbt 1. For some reason scripted requires src/doc jars of sbt, so switch back to using `publishAll` rather than `publishLocalBinAll`. :( Also, the sys.prop change in scripted is to force log4j2 to not use a thread context classloader, and avoid the following: ERROR StatusLogger Unable to create custom ContextSelector. Falling back to default. java.lang.ClassCastException: Cannot cast org.apache.logging.log4j.core.async.AsyncLoggerContextSelector to org.apache.logging.log4j.core.selector.ContextSelector at java.lang.Class.cast(Class.java:3369) at org.apache.logging.log4j.util.LoaderUtil.newCheckedInstanceOf(LoaderUtil.java:201) at org.apache.logging.log4j.util.LoaderUtil.newCheckedInstanceOfProperty(LoaderUtil.java:226) at org.apache.logging.log4j.core.impl.Log4jContextFactory.createContextSelector(Log4jContextFactory.java:97) at org.apache.logging.log4j.core.impl.Log4jContextFactory.<init>(Log4jContextFactory.java:58) at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.lang.reflect.Constructor.newInstance(Constructor.java:423) at java.lang.Class.newInstance(Class.java:442) at org.apache.logging.log4j.LogManager.<clinit>(LogManager.java:94) at org.apache.logging.log4j.spi.ThreadContextMapFactory.createThreadContextMap(ThreadContextMapFactory.java:73) at org.apache.logging.log4j.ThreadContext.init(ThreadContext.java:223) at org.apache.logging.log4j.ThreadContext.<clinit>(ThreadContext.java:202) at org.apache.logging.log4j.core.impl.ContextDataInjectorFactory.createDefaultInjector(ContextDataInjectorFactory.java:83) at org.apache.logging.log4j.core.impl.ContextDataInjectorFactory.createInjector(ContextDataInjectorFactory.java:67) at org.apache.logging.log4j.core.lookup.ContextMapLookup.<init>(ContextMapLookup.java:34) at org.apache.logging.log4j.core.lookup.Interpolator.<init>(Interpolator.java:117) at org.apache.logging.log4j.core.config.AbstractConfiguration.<init>(AbstractConfiguration.java:125) at org.apache.logging.log4j.core.config.DefaultConfiguration.<init>(DefaultConfiguration.java:46) at org.apache.logging.log4j.core.layout.PatternLayout$Builder.build(PatternLayout.java:650) at org.apache.logging.log4j.core.layout.PatternLayout.createDefaultLayout(PatternLayout.java:487) at sbt.internal.util.ConsoleAppender.<init>(ConsoleAppender.scala:245) at sbt.internal.util.ConsoleAppender$.apply(ConsoleAppender.scala:196) at sbt.internal.util.ConsoleLogger.<init>(ConsoleAppender.scala:42) at sbt.internal.util.ConsoleLogger$.apply(ConsoleAppender.scala:34) at sbt.test.ScriptedRunner.run(ScriptedTests.scala:221) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at Scripted$.doScripted(Scripted.scala:125) at $0483e89d182e9d240274$.$anonfun$scriptedTask$5(build.sbt:301)
2017-05-03 16:52:36 +02:00
// publishLocalBinAll.value // TODO: Restore scripted needing only binary jars.
publishAll.value
// These two projects need to be visible in a repo even if the default
// local repository is hidden, so we publish them to an alternate location and add
// that alternate repo to the running scripted test (in Scripted.scriptedpreScripted).
// (altLocalPublish in interfaceProj).value
// (altLocalPublish in compileInterfaceProj).value
2017-04-21 09:14:31 +02:00
Scripted.doScripted(
(sbtLaunchJar in bundledLauncherProj).value,
(fullClasspath in scriptedSbtProj in Test).value,
(scalaInstance in scriptedSbtProj).value,
2017-04-21 09:14:31 +02:00
scriptedSource.value,
scriptedBufferLog.value,
result,
scriptedPrescripted.value,
scriptedLaunchOpts.value
)
2014-12-18 05:38:10 +01:00
}
2015-07-10 11:53:48 +02:00
def scriptedUnpublishedTask: Def.Initialize[InputTask[Unit]] = Def.inputTask {
val result = scriptedSource(dir => (s: State) => Scripted.scriptedParser(dir)).parsed
2017-04-21 09:14:31 +02:00
Scripted.doScripted(
(sbtLaunchJar in bundledLauncherProj).value,
(fullClasspath in scriptedSbtProj in Test).value,
(scalaInstance in scriptedSbtProj).value,
2017-04-21 09:14:31 +02:00
scriptedSource.value,
scriptedBufferLog.value,
result,
scriptedPrescripted.value,
scriptedLaunchOpts.value
)
2014-12-18 05:38:10 +01:00
}
lazy val publishLauncher = TaskKey[Unit]("publish-launcher")
2017-04-21 09:14:31 +02:00
def allProjects =
Seq(
collectionProj,
logicProj,
completeProj,
2017-04-21 09:14:31 +02:00
testingProj,
testAgentProj,
taskProj,
stdTaskProj,
runProj,
scriptedSbtProj,
scriptedPluginProj,
protocolProj,
actionsProj,
commandProj,
mainSettingsProj,
mainProj,
sbtProj,
2017-05-26 06:59:49 +02:00
bundledLauncherProj,
coreMacrosProj
2017-04-21 09:14:31 +02:00
)
2015-02-03 04:44:02 +01:00
lazy val nonRoots = allProjects.map(p => LocalProject(p.id))
2014-12-18 05:38:10 +01:00
2017-04-21 09:14:31 +02:00
def otherRootSettings =
Seq(
scripted := scriptedTask.evaluated,
scriptedUnpublished := scriptedUnpublishedTask.evaluated,
scriptedSource := (sourceDirectory in sbtProj).value / "sbt-test",
// scriptedPrescripted := { addSbtAlternateResolver _ },
scriptedLaunchOpts := List("-Xmx1500M", "-Xms512M", "-server"),
2017-04-21 09:14:31 +02:00
publishAll := { val _ = (publishLocal).all(ScopeFilter(inAnyProject)).value },
publishLocalBinAll := { val _ = (publishLocalBin).all(ScopeFilter(inAnyProject)).value },
aggregate in bintrayRelease := false
) ++ inConfig(Scripted.RepoOverrideTest)(
Seq(
2017-06-23 18:58:00 +02:00
scriptedPrescripted := (_ => ()),
scriptedLaunchOpts := List(
"-Xmx1500M",
"-Xms512M",
"-server",
"-Dsbt.override.build.repos=true",
s"""-Dsbt.repository.config=${scriptedSource.value / "repo.config"}"""
),
2017-04-21 09:14:31 +02:00
scripted := scriptedTask.evaluated,
scriptedUnpublished := scriptedUnpublishedTask.evaluated,
scriptedSource := (sourceDirectory in sbtProj).value / "repo-override-test"
))
// def addSbtAlternateResolver(scriptedRoot: File) = {
// val resolver = scriptedRoot / "project" / "AddResolverPlugin.scala"
// if (!resolver.exists) {
// IO.write(resolver, s"""import sbt._
// |import Keys._
// |
// |object AddResolverPlugin extends AutoPlugin {
// | override def requires = sbt.plugins.JvmPlugin
// | override def trigger = allRequirements
// |
// | override lazy val projectSettings = Seq(resolvers += alternativeLocalResolver)
// | lazy val alternativeLocalResolver = Resolver.file("$altLocalRepoName", file("$altLocalRepoPath"))(Resolver.ivyStylePatterns)
// |}
// |""".stripMargin)
// }
// }
lazy val docProjects: ScopeFilter = ScopeFilter(
2016-04-29 08:39:34 +02:00
inAnyProject -- inProjects(sbtRoot, sbtProj, scriptedSbtProj, scriptedPluginProj),
inConfigurations(Compile)
2014-12-18 05:38:10 +01:00
)
2014-12-18 23:40:20 +01:00
lazy val safeUnitTests = taskKey[Unit]("Known working tests (for both 2.10 and 2.11)")
lazy val safeProjects: ScopeFilter = ScopeFilter(
2017-04-21 09:14:31 +02:00
inProjects(mainSettingsProj, mainProj, actionsProj, runProj, stdTaskProj),
2014-12-18 23:40:20 +01:00
inConfigurations(Test)
)
2015-06-20 20:21:16 +02:00
lazy val otherUnitTests = taskKey[Unit]("Unit test other projects")
lazy val otherProjects: ScopeFilter = ScopeFilter(
2017-06-23 18:58:00 +02:00
inProjects(
testingProj,
testAgentProj,
taskProj,
scriptedSbtProj,
scriptedPluginProj,
commandProj,
mainSettingsProj,
mainProj,
sbtProj
),
2015-06-20 20:21:16 +02:00
inConfigurations(Test)
)
2014-12-18 23:40:20 +01:00
def customCommands: Seq[Setting[_]] = Seq(
commands += Command.command("setupBuildScala212") { state =>
s"""set scalaVersion in ThisBuild := "$scala212" """ ::
2014-12-18 23:40:20 +01:00
state
},
safeUnitTests := {
test.all(safeProjects).value
},
2015-06-20 20:21:16 +02:00
otherUnitTests := {
2016-02-24 16:02:22 +01:00
test.all(otherProjects).value
2015-06-20 20:42:26 +02:00
},
2014-12-18 23:40:20 +01:00
commands += Command.command("release-sbt-local") { state =>
"clean" ::
2017-04-21 09:14:31 +02:00
"so compile" ::
"so publishLocal" ::
"reload" ::
state
2014-12-18 23:40:20 +01:00
},
/** There are several complications with sbt's build.
* First is the fact that interface project is a Java-only project
* that uses source generator from datatype subproject in Scala 2.10.6.
*
* Second is the fact that all subprojects are released with crossPaths
* turned off for the sbt's Scala version 2.10.6, but some of them are also
* cross published against 2.11.1 with crossPaths turned on.
*
* `so compile` handles 2.10.x/2.11.x cross building.
*/
2014-12-18 23:40:20 +01:00
commands += Command.command("release-sbt") { state =>
// TODO - Any sort of validation
"clean" ::
2017-05-30 08:44:13 +02:00
"conscriptConfigs" ::
"compile" ::
"publishSigned" ::
"bundledLauncherProj/publishLauncher" ::
2015-02-21 03:09:43 +01:00
state
},
// stamp-version doesn't work with ++ or "so".
2015-02-21 03:09:43 +01:00
commands += Command.command("release-nightly") { state =>
"stamp-version" ::
"clean" ::
"compile" ::
"publish" ::
2015-04-22 06:28:47 +02:00
"bintrayRelease" ::
2014-12-18 23:40:20 +01:00
state
}
)