sbt/build.sbt

952 lines
38 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._
2018-07-31 02:28:42 +02:00
import local.Scripted
import scala.xml.{Node => XmlNode, NodeSeq => XmlNodeSeq, _}
import scala.xml.transform.{RewriteRule, RuleTransformer}
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",
2018-09-25 17:25:24 +02:00
version := "1.3.0-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("Apache-2.0" -> url("https://github.com/sbt/sbt/blob/0.13/LICENSE")),
2017-04-21 09:14:31 +02:00
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")),
2019-03-22 20:14:52 +01:00
Developer("eatkins", "Ethan Atkins", "@eatkins", url("https://github.com/eatkins")),
2018-01-26 15:19:14 +01:00
Developer(
"gkossakowski",
"Grzegorz Kossakowski",
"@gkossakowski",
url("https://github.com/gkossakowski")
),
2017-04-21 09:14:31 +02:00
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-04-21 09:14:31 +02:00
))
2018-03-06 20:20:31 +01:00
def commonSettings: Seq[Setting[_]] = Def.settings(
2018-02-01 15:53:05 +01:00
headerLicense := Some(HeaderLicense.Custom(
"""|sbt
|Copyright 2011 - 2018, Lightbend, Inc.
2018-02-01 15:53:05 +01:00
|Copyright 2008 - 2010, Mark Harrah
|Licensed under Apache License 2.0 (see LICENSE)
2018-02-01 15:53:05 +01:00
|""".stripMargin
)),
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/",
addCompilerPlugin("org.spire-math" % "kind-projector" % "0.9.4" cross CrossVersion.binary),
concurrentRestrictions in Global += Util.testExclusiveRestriction,
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"),
2019-03-22 07:28:14 +01:00
Compile / doc / scalacOptions ++= {
import scala.sys.process._
val devnull = ProcessLogger(_ => ())
val tagOrSha = ("git describe --exact-match" #|| "git rev-parse HEAD").lineStream(devnull).head
2018-02-22 02:33:45 +01:00
Seq(
"-sourcepath",
(baseDirectory in LocalRootProject).value.getAbsolutePath,
"-doc-source-url",
2019-03-22 07:28:14 +01:00
s"https://github.com/sbt/sbt/tree/$tagOrSha€{FILE_PATH}.scala"
2018-02-22 02:33:45 +01:00
)
},
2018-02-01 15:53:05 +01: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
)
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 (
mimaPreviousArtifacts := {
Seq(
"1.0.0", "1.0.1", "1.0.2", "1.0.3", "1.0.4",
2018-07-31 02:28:42 +02:00
"1.1.0", "1.1.1", "1.1.2", "1.1.3", "1.1.4", "1.1.5", "1.1.6",
2018-09-14 09:28:12 +02:00
"1.2.0", "1.2.1", "1.2.3"
).map { v =>
organization.value % moduleName.value % v cross (if (crossPaths.value) CrossVersion.binary else CrossVersion.disabled)
}.toSet
2018-03-12 18:21:22 +01:00
},
mimaBinaryIssueFilters ++= Seq(
// Changes in the internal package
2018-03-12 18:21:22 +01:00
exclude[DirectMissingMethodProblem]("sbt.internal.*"),
exclude[FinalClassProblem]("sbt.internal.*"),
exclude[FinalMethodProblem]("sbt.internal.*"),
exclude[IncompatibleResultTypeProblem]("sbt.internal.*"),
2018-10-02 16:51:20 +02:00
exclude[ReversedMissingMethodProblem]("sbt.internal.*")
2018-03-12 18:21:22 +01:00
),
2017-07-20 18:31:39 +02:00
)
val scriptedSbtReduxMimaSettings = Def settings (
mimaPreviousArtifacts := Set()
)
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,
2018-10-05 09:04:22 +02:00
onLoadMessage := {
""" __ __
| _____/ /_ / /_
| / ___/ __ \/ __/
| (__ ) /_/ / /_
| /____/_.___/\__/
|Welcome to the build for sbt.
|""".stripMargin +
(if (sys.props("java.specification.version") != "1.8")
s"""!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
| Java version is ${sys.props("java.specification.version")}. We recommend 1.8.
2018-10-05 09:04:22 +02:00
|!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!""".stripMargin
else "")
},
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,
// Parser is used publicly, so we can't break bincompat.
mimaBinaryIssueFilters := Seq(
exclude[DirectMissingMethodProblem]("sbt.internal.util.complete.History.this"),
2017-12-04 17:18:08 +01:00
),
)
2018-11-17 08:05:51 +01:00
.configure(addSbtIO, addSbtUtilControl, addSbtUtilLogging)
// 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),
2018-09-18 17:47:55 +02:00
Compile / scalacOptions += "-Ywarn-unused:-locals,-explicits,-privates",
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,
2018-03-07 21:31:24 +01:00
mimaBinaryIssueFilters ++= Seq(
// private[sbt]
exclude[IncompatibleMethTypeProblem]("sbt.TestStatus.write"),
exclude[IncompatibleResultTypeProblem]("sbt.TestStatus.read"),
2018-03-12 16:18:42 +01:00
// copy method was never meant to be public
exclude[DirectMissingMethodProblem]("sbt.protocol.testing.EndTestGroupErrorEvent.copy"),
exclude[DirectMissingMethodProblem]("sbt.protocol.testing.EndTestGroupErrorEvent.copy$default$*"),
exclude[DirectMissingMethodProblem]("sbt.protocol.testing.EndTestGroupEvent.copy"),
exclude[DirectMissingMethodProblem]("sbt.protocol.testing.EndTestGroupEvent.copy$default$*"),
exclude[DirectMissingMethodProblem]("sbt.protocol.testing.StartTestGroupEvent.copy"),
exclude[DirectMissingMethodProblem]("sbt.protocol.testing.StartTestGroupEvent.copy$default$*"),
exclude[DirectMissingMethodProblem]("sbt.protocol.testing.TestCompleteEvent.copy"),
exclude[DirectMissingMethodProblem]("sbt.protocol.testing.TestCompleteEvent.copy$default$*"),
exclude[DirectMissingMethodProblem]("sbt.protocol.testing.TestInitEvent.copy"),
exclude[DirectMissingMethodProblem]("sbt.protocol.testing.TestItemDetail.copy"),
exclude[DirectMissingMethodProblem]("sbt.protocol.testing.TestItemDetail.copy$default$*"),
exclude[DirectMissingMethodProblem]("sbt.protocol.testing.TestItemEvent.copy"),
exclude[DirectMissingMethodProblem]("sbt.protocol.testing.TestItemEvent.copy$default$*"),
exclude[DirectMissingMethodProblem]("sbt.protocol.testing.TestStringEvent.copy"),
exclude[DirectMissingMethodProblem]("sbt.protocol.testing.TestStringEvent.copy$default$1"),
//no reason to use
exclude[DirectMissingMethodProblem]("sbt.JUnitXmlTestsListener.testSuite"),
2018-03-12 16:18:42 +01:00
)
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,
2019-03-08 21:26:15 +01:00
mimaBinaryIssueFilters ++= Seq(
// ok because sbt.ExecuteProgress has been under private[sbt]
exclude[IncompatibleResultTypeProblem]("sbt.ExecuteProgress.initial"),
exclude[DirectMissingMethodProblem]("sbt.ExecuteProgress.*"),
exclude[ReversedMissingMethodProblem]("sbt.ExecuteProgress.*"),
2019-03-08 21:26:15 +01:00
)
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",
2018-09-18 17:47:55 +02:00
Compile / scalacOptions += "-Ywarn-unused:-locals,-explicits,-privates",
2017-05-12 00:33:12 +02:00
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,
2018-03-12 16:18:42 +01:00
mimaBinaryIssueFilters ++= Seq(
// copy method was never meant to be public
exclude[DirectMissingMethodProblem]("sbt.ForkOptions.copy"),
exclude[DirectMissingMethodProblem]("sbt.ForkOptions.copy$default$*"),
exclude[DirectMissingMethodProblem]("sbt.OutputStrategy#BufferedOutput.copy"),
exclude[DirectMissingMethodProblem]("sbt.OutputStrategy#BufferedOutput.copy$default$*"),
exclude[DirectMissingMethodProblem]("sbt.OutputStrategy#CustomOutput.copy"),
exclude[DirectMissingMethodProblem]("sbt.OutputStrategy#CustomOutput.copy$default$*"),
exclude[DirectMissingMethodProblem]("sbt.OutputStrategy#LoggedOutput.copy"),
exclude[DirectMissingMethodProblem]("sbt.OutputStrategy#LoggedOutput.copy$default$*"),
)
2017-04-21 09:14:31 +02:00
)
.configure(addSbtIO, addSbtUtilLogging, addSbtUtilControl, addSbtCompilerClasspath)
2014-12-18 05:38:10 +01:00
2018-02-01 15:53:11 +01:00
val sbtProjDepsCompileScopeFilter =
ScopeFilter(inDependencies(LocalProject("sbtProj"), includeRoot = false), inConfigurations(Compile))
lazy val scriptedSbtReduxProj = (project in file("scripted-sbt-redux"))
2017-04-21 09:14:31 +02:00
.dependsOn(commandProj)
.settings(
baseSettings,
name := "Scripted sbt Redux",
2017-07-20 18:31:39 +02:00
libraryDependencies ++= Seq(launcherInterface % "provided"),
2018-02-01 15:53:11 +01:00
resourceGenerators in Compile += Def task {
val mainClassDir = (classDirectory in Compile in LocalProject("sbtProj")).value
val testClassDir = (classDirectory in Test in LocalProject("sbtProj")).value
val classDirs = (classDirectory all sbtProjDepsCompileScopeFilter).value
val extDepsCp = (externalDependencyClasspath in Compile in LocalProject("sbtProj")).value
val cpStrings = (mainClassDir +: testClassDir +: classDirs) ++ extDepsCp.files map (_.toString)
val file = (resourceManaged in Compile).value / "RunFromSource.classpath"
IO.writeLines(file, cpStrings)
List(file)
},
2017-07-20 18:31:39 +02:00
mimaSettings,
scriptedSbtReduxMimaSettings,
)
.configure(addSbtIO, addSbtUtilLogging, addSbtCompilerInterface, addSbtUtilScripted, addSbtLmCore)
lazy val scriptedSbtOldProj = (project in file("scripted-sbt-old"))
.dependsOn(scriptedSbtReduxProj)
.settings(
baseSettings,
name := "Scripted sbt",
mimaSettings,
mimaBinaryIssueFilters ++= Seq(
// sbt.test package is renamed to sbt.scriptedtest.
exclude[MissingClassProblem]("sbt.test.*"),
exclude[DirectMissingMethodProblem]("sbt.test.*"),
exclude[IncompatibleMethTypeProblem]("sbt.test.*"),
),
2017-04-21 09:14:31 +02:00
)
2014-12-18 05:38:10 +01:00
lazy val scriptedPluginProj = (project in file("scripted-plugin"))
2017-04-21 09:14:31 +02:00
.settings(
baseSettings,
2017-07-20 18:31:39 +02:00
name := "Scripted Plugin",
mimaSettings,
mimaBinaryIssueFilters ++= Seq(
// scripted plugin has moved into sbt mothership.
exclude[MissingClassProblem]("sbt.ScriptedPlugin*")
),
2017-04-21 09:14:31 +02:00
)
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-12-05 17:16:26 +01:00
mimaBinaryIssueFilters ++= Seq(
// Removed unused private[sbt] nested class
exclude[MissingClassProblem]("sbt.Doc$Scaladoc"),
// Removed no longer used private[sbt] method
exclude[DirectMissingMethodProblem]("sbt.Doc.generate"),
exclude[DirectMissingMethodProblem]("sbt.compiler.Eval.filesModifiedBytes"),
exclude[DirectMissingMethodProblem]("sbt.compiler.Eval.fileModifiedBytes"),
2017-12-05 17:16:26 +01:00
),
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)
.dependsOn(collectionProj)
2017-04-21 09:14:31 +02:00
.settings(
2016-12-01 09:14:07 +01:00
testedBaseSettings,
name := "Protocol",
2018-01-30 06:43:30 +01:00
libraryDependencies ++= Seq(sjsonNewScalaJson.value, ipcSocket),
2018-09-18 17:47:55 +02:00
Compile / scalacOptions += "-Ywarn-unused:-locals,-explicits,-privates",
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,
2018-03-12 16:18:42 +01:00
mimaBinaryIssueFilters ++= Seq(
// copy method was never meant to be public
exclude[DirectMissingMethodProblem]("sbt.protocol.ChannelAcceptedEvent.copy"),
exclude[DirectMissingMethodProblem]("sbt.protocol.ChannelAcceptedEvent.copy$default$1"),
exclude[DirectMissingMethodProblem]("sbt.protocol.ExecCommand.copy"),
exclude[DirectMissingMethodProblem]("sbt.protocol.ExecCommand.copy$default$1"),
exclude[DirectMissingMethodProblem]("sbt.protocol.ExecCommand.copy$default$2"),
exclude[DirectMissingMethodProblem]("sbt.protocol.ExecStatusEvent.copy"),
exclude[DirectMissingMethodProblem]("sbt.protocol.ExecStatusEvent.copy$default$*"),
exclude[DirectMissingMethodProblem]("sbt.protocol.ExecutionEvent.copy"),
exclude[DirectMissingMethodProblem]("sbt.protocol.ExecutionEvent.copy$default$*"),
exclude[DirectMissingMethodProblem]("sbt.protocol.InitCommand.copy"),
exclude[DirectMissingMethodProblem]("sbt.protocol.InitCommand.copy$default$*"),
exclude[DirectMissingMethodProblem]("sbt.protocol.LogEvent.copy"),
exclude[DirectMissingMethodProblem]("sbt.protocol.LogEvent.copy$default$*"),
exclude[DirectMissingMethodProblem]("sbt.protocol.SettingQuery.copy"),
exclude[DirectMissingMethodProblem]("sbt.protocol.SettingQuery.copy$default$1"),
exclude[DirectMissingMethodProblem]("sbt.protocol.SettingQueryFailure.copy"),
exclude[DirectMissingMethodProblem]("sbt.protocol.SettingQueryFailure.copy$default$*"),
exclude[DirectMissingMethodProblem]("sbt.protocol.SettingQuerySuccess.copy"),
exclude[DirectMissingMethodProblem]("sbt.protocol.SettingQuerySuccess.copy$default$*"),
// ignore missing methods in sbt.internal
exclude[DirectMissingMethodProblem]("sbt.internal.*"),
)
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),
2018-09-18 17:47:55 +02:00
Compile / scalacOptions += "-Ywarn-unused:-locals,-explicits,-privates",
// Removing -Xfatal-warnings is necessary because BasicKeys contains a Key for a deprecated class.
Compile / scalacOptions -= "-Xfatal-warnings",
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(
// dropped private[sbt] method
exclude[DirectMissingMethodProblem]("sbt.BasicCommands.compatCommands"),
// dropped mainly internal command strings holder
exclude[MissingClassProblem]("sbt.BasicCommandStrings$Compat$"),
exclude[DirectMissingMethodProblem]("sbt.BasicCommands.rebootOptionParser"),
// 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"),
2018-01-30 06:43:30 +01:00
// Replace nailgun socket stuff
exclude[MissingClassProblem]("sbt.internal.NG*"),
exclude[MissingClassProblem]("sbt.internal.ReferenceCountedFileDescriptor"),
2018-03-12 16:18:42 +01:00
2018-03-12 18:13:17 +01:00
// made private[sbt] method private[this]
exclude[DirectMissingMethodProblem]("sbt.State.handleException"),
2018-03-12 16:18:42 +01:00
// copy method was never meant to be public
exclude[DirectMissingMethodProblem]("sbt.CommandSource.copy"),
exclude[DirectMissingMethodProblem]("sbt.CommandSource.copy$default$*"),
exclude[DirectMissingMethodProblem]("sbt.Exec.copy"),
exclude[DirectMissingMethodProblem]("sbt.Exec.copy$default$*"),
2018-06-26 04:34:55 +02:00
// internal
exclude[ReversedMissingMethodProblem]("sbt.internal.client.ServerConnection.*"),
),
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,
Add global file repository task Every time that the compile task is run, there are potentially a large number of iops that must occur in order for sbt to generate the source file list as well as for zinc to check which files have changed since the last build. This can lead to a noticeable delay between when a build is started (either manually or by triggered execution) and when compilation actually begins. To reduce this latency, I am adding a global view of the file system that will be stored in BasicKeys.globalFileTreeView. To make this work, I introduce the StampedFile trait, which augments the java.io.File class with a stamp method that returns the zinc stamp for the file. For source files, this will be a hash of the file, while for binaries, it is just the last modified time. In order to gain access to the sbt.internal.inc.Stamper class, I had to append addSbtZinc to the commandProj configurations. This view may or may not use an in-memory cache of the file system tree to return the results. Because there is always the risk of the cache getting out of sync with the actual file system, I both make it optional to use a cache and provide a mechanism for flushing the cache. Moreover, the in-memory cache implementation in sbt.io, which is backed by a swoval FileTreeRepository, has the property that touching a monitored directory invalidates the entire directory within the cache, so the flush command isn't even strictly needed in general. Because caching is optional, the global is of a FileTreeDataView, which doesn't specify a caching strategy. Subsequent commits will make use of this to potentially speed up incremental compilation by caching the Stamps of the source files so that zinc does not need to compute the hashes itself and will allow for continuous builds to use the cache to monitor events instead of creating a new, standalone FileEventMonitor.
2018-08-26 01:43:48 +02:00
addSbtLmCore,
addSbtZinc
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(
baseSettings,
name := "Core Macros",
2017-07-20 18:31:39 +02:00
libraryDependencies += "org.scala-lang" % "scala-compiler" % scalaVersion.value,
mimaSettings,
)
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",
BuildInfoPlugin.buildInfoDefaultSettings,
addBuildInfoToConfig(Test),
buildInfoObject in Test := "TestBuildInfo",
buildInfoKeys in Test := Seq[BuildInfoKey](
classDirectory in Compile,
classDirectory in Test,
// WORKAROUND https://github.com/sbt/sbt-buildinfo/issues/117
BuildInfoKey.map((dependencyClasspath in Compile).taskValue) { case (ident, cp) => ident -> cp.files },
),
2017-07-20 18:31:39 +02:00
mimaSettings,
mimaBinaryIssueFilters ++= Seq(
exclude[DirectMissingMethodProblem]("sbt.Scope.display012StyleMasked"),
// added a method to a sealed trait
exclude[InheritedNewAbstractMethodProblem]("sbt.Scoped.canEqual"),
exclude[InheritedNewAbstractMethodProblem]("sbt.ScopedTaskable.canEqual"),
),
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,
scriptedSbtReduxProj, scriptedPluginProj)
2017-04-21 09:14:31 +02:00
.settings(
testedBaseSettings,
2014-12-18 05:38:10 +01:00
name := "Main",
2018-10-05 19:32:40 +02:00
checkPluginCross := {
val sv = scalaVersion.value
val xs = IO.readLines(baseDirectory.value / "src" / "main" / "scala" / "sbt" / "PluginCross.scala")
if (xs exists { s => s.contains(s""""$sv"""") }) ()
else sys.error("PluginCross.scala does not match up with the scalaVersion " + sv)
},
libraryDependencies ++= scalaXml.value ++ Seq(launcherInterface) ++ log4jDependencies ++ Seq(scalaCacheCaffeine),
2018-09-18 17:47:55 +02:00
Compile / scalacOptions -= "-Xfatal-warnings",
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(
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
// New and changed methods on KeyIndex. internal.
exclude[ReversedMissingMethodProblem]("sbt.internal.KeyIndex.*"),
2019-01-04 15:55:28 +01:00
// internal
exclude[IncompatibleMethTypeProblem]("sbt.internal.server.LanguageServerReporter.*"),
2017-12-14 14:41:40 +01:00
// Changed signature or removed private[sbt] methods
exclude[DirectMissingMethodProblem]("sbt.Classpaths.unmanagedLibs0"),
exclude[DirectMissingMethodProblem]("sbt.Defaults.allTestGroupsTask"),
exclude[DirectMissingMethodProblem]("sbt.Plugins.topologicalSort"),
exclude[IncompatibleMethTypeProblem]("sbt.Defaults.allTestGroupsTask"),
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,
addSbtLmImpl,
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, scriptedSbtReduxProj % "test->test")
2017-04-21 09:14:31 +02:00
.settings(
testedBaseSettings,
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,
BuildInfoPlugin.buildInfoDefaultSettings,
addBuildInfoToConfig(Test),
BuildInfoPlugin.buildInfoDefaultSettings,
buildInfoObject in Test := "TestBuildInfo",
buildInfoKeys in Test := Seq[BuildInfoKey](
version,
2018-02-22 17:48:09 +01:00
// WORKAROUND https://github.com/sbt/sbt-buildinfo/issues/117
BuildInfoKey.map((fullClasspath in Compile).taskValue) { case (ident, cp) => ident -> cp.files },
BuildInfoKey.map((dependencyClasspath in Compile).taskValue) { case (ident, cp) => ident -> cp.files },
classDirectory in Compile,
classDirectory in Test,
),
2018-03-26 16:37:25 +02:00
Test / run / connectInput := true,
Test / run / outputStrategy := Some(StdoutOutput),
Test / run / fork := true,
2017-04-21 09:14:31 +02:00
)
.configure(addSbtIO, addSbtCompilerBridge)
2017-10-20 05:18:43 +02:00
lazy val sbtBig = (project in file(".big"))
.dependsOn(sbtProj)
.settings(
name := "sbt-big",
normalizedName := "sbt-big",
crossPaths := false,
assemblyShadeRules.in(assembly) := {
val packagesToBeShaded = Seq(
"fastparse",
"jawn",
"scalapb",
)
packagesToBeShaded.map( prefix => {
ShadeRule.rename(s"$prefix.**" -> s"sbt.internal.$prefix.@1").inAll
})
},
assemblyMergeStrategy in assembly := {
case "LICENSE" | "NOTICE" => MergeStrategy.first
case x => (assemblyMergeStrategy in assembly).value(x)
},
artifact.in(Compile, packageBin) := artifact.in(Compile, assembly).value,
assemblyOption.in(assembly) ~= { _.copy(includeScala = false) },
addArtifact(artifact.in(Compile, packageBin), assembly),
pomPostProcess := { node =>
new RuleTransformer(new RewriteRule {
override def transform(node: XmlNode): XmlNodeSeq = node match {
case e: Elem if node.label == "dependency" =>
Comment(
"the dependency that was here has been absorbed via sbt-assembly"
)
case _ => node
}
}).transform(node).head
},
)
lazy val sbtIgnoredProblems = {
2017-11-29 22:45:02 +01:00
Vector(
exclude[MissingClassProblem]("buildinfo.BuildInfo"),
exclude[MissingClassProblem]("buildinfo.BuildInfo$"),
// 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"),
2018-07-01 09:13:09 +02:00
exclude[ReversedMissingMethodProblem]("sbt.Import.SemanticSelector"),
exclude[ReversedMissingMethodProblem]("sbt.Import.sbt$Import$_setter_$SemanticSelector_="),
2017-11-29 22:45:02 +01:00
// 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) = {
import scala.sys.process._
try {
2017-12-19 06:17:46 +01:00
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 {
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
2018-02-01 15:53:11 +01:00
(sbtProj / Test / compile).value // make sure sbt.RunFromSourceMain is compiled
2017-04-21 09:14:31 +02:00
Scripted.doScripted(
(sbtLaunchJar in bundledLauncherProj).value,
(fullClasspath in scriptedSbtReduxProj in Test).value,
(scalaInstance in scriptedSbtReduxProj).value,
2017-04-21 09:14:31 +02:00
scriptedSource.value,
scriptedBufferLog.value,
2018-01-24 14:42:18 +01:00
Def.setting(Scripted.scriptedParser(scriptedSource.value)).parsed,
2017-04-21 09:14:31 +02:00
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 {
2017-04-21 09:14:31 +02:00
Scripted.doScripted(
(sbtLaunchJar in bundledLauncherProj).value,
(fullClasspath in scriptedSbtReduxProj in Test).value,
(scalaInstance in scriptedSbtReduxProj).value,
2017-04-21 09:14:31 +02:00
scriptedSource.value,
scriptedBufferLog.value,
2018-01-24 14:42:18 +01:00
Def.setting(Scripted.scriptedParser(scriptedSource.value)).parsed,
2017-04-21 09:14:31 +02:00
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,
scriptedSbtReduxProj,
scriptedSbtOldProj,
2017-04-21 09:14:31 +02:00
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
2018-07-31 02:28:42 +02:00
ThisBuild / scriptedBufferLog := true
ThisBuild / scriptedPrescripted := { _ => }
2017-04-21 09:14:31 +02:00
def otherRootSettings =
Seq(
scripted := scriptedTask.evaluated,
scriptedUnpublished := scriptedUnpublishedTask.evaluated,
scriptedSource := (sourceDirectory in sbtProj).value / "sbt-test",
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
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"
))
lazy val docProjects: ScopeFilter = ScopeFilter(
inAnyProject -- inProjects(sbtRoot, sbtProj, scriptedSbtReduxProj, scriptedSbtOldProj, 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(
inAnyProject -- inProjects(sbtRoot, sbtProj),
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(
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
},
commands += Command.command("whitesourceOnPush") { state =>
sys.env.get("TRAVIS_EVENT_TYPE") match {
case Some("push") =>
"whitesourceCheckPolicies" ::
"whitesourceUpdate" ::
state
case _ => state
}
},
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
},
2018-02-21 08:28:33 +01:00
commands += Command.command("publishLocalAllModule") { state =>
val extracted = Project.extract(state)
import extracted._
val sv = get(scalaVersion)
val projs = structure.allProjectRefs
val ioOpt = projs find { case ProjectRef(_, id) => id == "ioRoot"; case _ => false }
val utilOpt = projs find { case ProjectRef(_, id) => id == "utilRoot"; case _ => false }
val lmOpt = projs find { case ProjectRef(_, id) => id == "lmRoot"; case _ => false }
val zincOpt = projs find { case ProjectRef(_, id) => id == "zincRoot"; case _ => false }
(ioOpt map { case ProjectRef(build, _) => "{" + build.toString + "}/publishLocal" }).toList :::
(utilOpt map { case ProjectRef(build, _) => "{" + build.toString + "}/publishLocal" }).toList :::
(lmOpt map { case ProjectRef(build, _) => "{" + build.toString + "}/publishLocal" }).toList :::
(zincOpt map { case ProjectRef(build, _) =>
val zincSv = get(scalaVersion in ProjectRef(build, "zinc"))
val csv = get(crossScalaVersions in ProjectRef(build, "compilerBridge")).toList
(csv flatMap { bridgeSv =>
s"++$bridgeSv" :: ("{" + build.toString + "}compilerBridge/publishLocal") :: Nil
}) :::
List(s"++$zincSv", "{" + build.toString + "}/publishLocal")
}).getOrElse(Nil) :::
List(s"++$sv", "publishLocal") :::
state
},
/** 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
}
)
ThisBuild / whitesourceProduct := "Lightbend Reactive Platform"
ThisBuild / whitesourceAggregateProjectName := {
// note this can get detached on tag build etc
val b = (ThisBuild / git.gitCurrentBranch).value
val Stable = """1\.([0-9]+)\.x""".r
b match {
case Stable(y) => "sbt-1." + y.toString + "-stable"
case _ => "sbt-master"
}
}
ThisBuild / whitesourceAggregateProjectToken := {
(ThisBuild / whitesourceAggregateProjectName).value match {
case "sbt-master" => "e7a1e55518c0489a98e9c7430c8b2ccd53d9f97c12ed46148b592ebe4c8bf128"
case "sbt-1.2-stable" => "54f2313767aa47198971e65595670ee16e1ad0000d20458588e72d3ac2c34763"
case _ => "" // it's ok to fail here
}
}
ThisBuild / whitesourceIgnoredScopes ++= Seq("plugin", "scalafmt", "sxr")
ThisBuild / whitesourceFailOnError := sys.env.contains("WHITESOURCE_PASSWORD") // fail if pwd is present
ThisBuild / whitesourceForceCheckAllDependencies := true