sbt/build.sbt

376 lines
14 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
2015-06-22 15:52:38 +02:00
import com.typesafe.tools.mima.core._, ProblemFilters._
import com.typesafe.tools.mima.plugin.MimaKeys.{ binaryIssueFilters, previousArtifact}
import com.typesafe.tools.mima.plugin.MimaPlugin.mimaDefaultSettings
2015-02-06 19:48:12 +01:00
// ThisBuild settings take lower precedence,
// but can be shared across the multi projects.
2015-08-19 13:12:14 +02:00
def buildLevelSettings: Seq[Setting[_]] = inThisBuild(Seq(
organization := "org.scala-sbt",
2015-09-16 00:19:05 +02:00
version := "1.0.0-SNAPSHOT",
2016-05-09 03:35:46 +02:00
description := "sbt is an interactive build tool",
2016-05-05 20:38:24 +02:00
bintrayOrganization := Some("sbt"),
bintrayRepository := {
2016-05-08 21:29:28 +02:00
if (!isSnapshot.value) "maven-releases"
2016-05-05 20:38:24 +02:00
else "maven-snapshots"
},
2015-08-19 13:12:14 +02:00
bintrayPackage := "sbt",
2015-09-11 11:00:34 +02:00
bintrayReleaseOnPublish := false,
2016-05-09 03:35:46 +02:00
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")),
2015-09-11 11:00:34 +02:00
resolvers += Resolver.mavenLocal
2015-08-19 13:12:14 +02:00
))
2015-02-06 19:48:12 +01:00
2015-06-22 15:52:38 +02:00
def commonSettings: Seq[Setting[_]] = Seq[SettingsDefinition](
2016-04-29 08:39:34 +02:00
scalaVersion := scala211,
2014-12-18 05:38:10 +01:00
componentID := None,
resolvers += Resolver.typesafeIvyRepo("releases"),
resolvers += Resolver.sonatypeRepo("snapshots"),
2016-10-07 20:37:25 +02:00
resolvers += "bintray-sbt-maven-releases" at "https://dl.bintray.com/sbt/maven-releases/",
2014-12-18 05:38:10 +01:00
concurrentRestrictions in Global += Util.testExclusiveRestriction,
testOptions += Tests.Argument(TestFrameworks.ScalaCheck, "-w", "1"),
javacOptions in compile ++= Seq("-target", "6", "-source", "6", "-Xlint", "-Xlint:-serial"),
2015-02-03 04:44:02 +01:00
incOptions := incOptions.value.withNameHashing(true),
2016-09-13 07:15:57 +02:00
crossScalaVersions := Seq(scala211),
2015-04-20 07:20:23 +02:00
bintrayPackage := (bintrayPackage in ThisBuild).value,
2015-06-22 15:52:38 +02:00
bintrayRepository := (bintrayRepository in ThisBuild).value,
mimaDefaultSettings,
publishArtifact in Test := false,
2015-06-22 15:52:38 +02:00
previousArtifact := None, // Some(organization.value % moduleName.value % "1.0.0"),
binaryIssueFilters ++= Seq(
)
) flatMap (_.settings)
2014-12-18 05:38:10 +01:00
def minimalSettings: Seq[Setting[_]] =
commonSettings ++ customCommands ++
2014-12-18 23:40:20 +01:00
publishPomSettings ++ Release.javaVersionCheckSettings
2014-12-18 05:38:10 +01:00
def baseSettings: Seq[Setting[_]] =
minimalSettings ++ Seq(projectComponent) ++ baseScalacOptions ++ Licensed.settings ++ Formatting.settings
def testedBaseSettings: Seq[Setting[_]] =
baseSettings ++ testDependencies
lazy val sbtRoot: Project = (project in file(".")).
enablePlugins(ScriptedPlugin).
configs(Sxr.sxrConf).
2014-12-18 05:38:10 +01:00
aggregate(nonRoots: _*).
settings(
buildLevelSettings,
minimalSettings,
rootSettings,
publish := {},
publishLocal := {}
)
// This is used to configure an sbt-launcher for this version of sbt.
lazy val bundledLauncherProj =
(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,
2016-04-29 08:39:34 +02:00
crossPaths := false,
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
/* **** Intermediate-level Modules **** */
// Runner for uniform test interface
lazy val testingProj = (project in file("testing")).
2015-09-14 09:27:22 +02:00
dependsOn(testAgentProj).
2014-12-18 05:38:10 +01:00
settings(
baseSettings,
2014-12-18 05:38:10 +01:00
name := "Testing",
2015-09-14 09:27:22 +02:00
libraryDependencies ++= Seq(sbtIO, testInterface,launcherInterface, compilerClasspath, utilLogging)
2014-12-18 05:38:10 +01:00
)
// Testing agent for running tests in a separate process.
lazy val testAgentProj = (project in file("testing") / "agent").
settings(
minimalSettings,
2016-05-05 20:38:24 +02:00
crossScalaVersions := Seq(scala211),
crossPaths := false,
autoScalaLibrary := false,
2014-12-18 05:38:10 +01:00
name := "Test Agent",
2014-12-18 13:57:05 +01:00
libraryDependencies += testInterface
2014-12-18 05:38:10 +01:00
)
// Basic task engine
2016-05-06 22:01:49 +02:00
lazy val taskProj = (project in file("tasks")).
2014-12-18 05:38:10 +01:00
settings(
testedBaseSettings,
2015-09-14 09:27:22 +02:00
name := "Tasks",
libraryDependencies ++= Seq(utilControl, utilCollection)
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.
2016-05-06 22:01:49 +02:00
lazy val stdTaskProj = (project in file("tasks-standard")).
2015-09-14 09:27:22 +02:00
dependsOn (taskProj % "compile;test->test").
2014-12-18 05:38:10 +01:00
settings(
testedBaseSettings,
2014-12-18 05:38:10 +01:00
name := "Task System",
2015-09-14 09:27:22 +02:00
testExclusive,
libraryDependencies ++= Seq(utilCollection, utilLogging, sbtIO)
2014-12-18 05:38:10 +01:00
)
// Embedded Scala code runner
lazy val runProj = (project in file("run")).
settings(
testedBaseSettings,
2015-09-14 09:27:22 +02:00
name := "Run",
libraryDependencies ++= Seq(sbtIO,
utilLogging, compilerClasspath)
2014-12-18 05:38:10 +01:00
)
lazy val scriptedSbtProj = (project in scriptedPath / "sbt").
2016-01-26 14:51:14 +01:00
dependsOn(commandProj).
2014-12-18 05:38:10 +01:00
settings(
baseSettings,
name := "Scripted sbt",
2015-09-14 09:27:22 +02:00
libraryDependencies ++= Seq(launcherInterface % "provided",
2016-01-26 14:51:14 +01:00
sbtIO, utilLogging, compilerInterface, utilScripted)
2014-12-18 05:38:10 +01:00
)
lazy val scriptedPluginProj = (project in scriptedPath / "plugin").
2015-09-14 09:27:22 +02:00
dependsOn(sbtProj).
2014-12-18 05:38:10 +01:00
settings(
baseSettings,
2015-09-14 09:27:22 +02:00
name := "Scripted Plugin",
libraryDependencies ++= Seq(compilerClasspath)
2014-12-18 05:38:10 +01:00
)
// Implementation and support code for defining actions.
2016-05-06 22:01:49 +02:00
lazy val actionsProj = (project in file("main-actions")).
2015-09-14 09:27:22 +02:00
dependsOn(runProj, stdTaskProj, taskProj, testingProj).
2014-12-18 05:38:10 +01:00
settings(
testedBaseSettings,
2015-09-14 09:27:22 +02:00
name := "Actions",
libraryDependencies ++= Seq(compilerClasspath, utilCompletion, compilerApiInfo,
2016-05-04 16:44:31 +02:00
zinc, compilerIvyIntegration, compilerInterface,
2015-09-14 09:27:22 +02:00
sbtIO, utilLogging, utilRelation, libraryManagement, utilTracking)
2014-12-18 05:38:10 +01:00
)
// General command support and core commands not specific to a build system
2016-05-06 22:01:49 +02:00
lazy val commandProj = (project in file("main-command")).
enablePlugins(DatatypePlugin, JsonCodecPlugin).
2014-12-18 05:38:10 +01:00
settings(
testedBaseSettings,
name := "Command",
2015-09-14 09:27:22 +02:00
libraryDependencies ++= Seq(launcherInterface, compilerInterface,
sbtIO, utilLogging, utilCompletion, compilerClasspath, sjsonNewScalaJson),
sourceManaged in (Compile, generateDatatypes) := baseDirectory.value / "src" / "main" / "datatype-scala"
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
2016-05-06 22:01:49 +02:00
lazy val mainSettingsProj = (project in file("main-settings")).
2015-09-14 09:27:22 +02:00
dependsOn(commandProj, stdTaskProj).
2014-12-18 05:38:10 +01:00
settings(
testedBaseSettings,
2014-12-18 05:38:10 +01:00
name := "Main Settings",
2016-05-02 10:17:22 +02:00
libraryDependencies ++= Seq(utilCache, utilApplyMacro, compilerInterface, utilRelation,
2015-09-14 09:27:22 +02:00
utilLogging, sbtIO, utilCompletion, compilerClasspath, libraryManagement)
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.
2016-05-06 22:01:49 +02:00
lazy val mainProj = (project in file("main")).
dependsOn(actionsProj, mainSettingsProj, runProj, commandProj).
2014-12-18 05:38:10 +01:00
settings(
testedBaseSettings,
2014-12-18 05:38:10 +01:00
name := "Main",
2015-09-14 09:27:22 +02:00
libraryDependencies ++= scalaXml.value ++ Seq(launcherInterface, compilerInterface,
2016-05-04 16:44:31 +02:00
sbtIO, utilLogging, utilLogic, libraryManagement, zincCompile)
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)
2016-05-06 22:01:49 +02:00
lazy val sbtProj = (project in file("sbt")).
2015-09-14 09:27:22 +02:00
dependsOn(mainProj, scriptedSbtProj % "test->test").
2014-12-18 05:38:10 +01:00
settings(
baseSettings,
2014-12-18 05:38:10 +01:00
name := "sbt",
2015-09-14 09:27:22 +02:00
normalizedName := "sbt",
2016-05-08 21:01:00 +02:00
crossScalaVersions := Seq(scala211),
crossPaths := false,
2016-11-23 16:17:34 +01:00
libraryDependencies ++= Seq(compilerBridge)
2014-12-18 05:38:10 +01:00
)
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
publishLocalBinAll.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
Scripted.doScripted((sbtLaunchJar in bundledLauncherProj).value, (fullClasspath in scriptedSbtProj in Test).value,
(scalaInstance in scriptedSbtProj).value,
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
Scripted.doScripted((sbtLaunchJar in bundledLauncherProj).value, (fullClasspath in scriptedSbtProj in Test).value,
(scalaInstance in scriptedSbtProj).value,
scriptedSource.value, scriptedBufferLog.value, result, scriptedPrescripted.value, scriptedLaunchOpts.value)
2014-12-18 05:38:10 +01:00
}
lazy val publishLauncher = TaskKey[Unit]("publish-launcher")
lazy val myProvided = config("provided") intransitive
2015-09-14 09:27:22 +02:00
def allProjects = Seq(
testingProj, testAgentProj, taskProj, stdTaskProj, runProj,
2016-01-26 14:51:14 +01:00
scriptedSbtProj, scriptedPluginProj,
actionsProj, commandProj, mainSettingsProj, mainProj, sbtProj, bundledLauncherProj)
2015-02-03 04:44:02 +01:00
2014-12-18 05:38:10 +01:00
def projectsWithMyProvided = allProjects.map(p => p.copy(configurations = (p.configurations.filter(_ != Provided)) :+ myProvided))
lazy val nonRoots = projectsWithMyProvided.map(p => LocalProject(p.id))
2015-04-20 07:20:23 +02:00
def rootSettings = fullDocSettings ++
2015-06-09 17:20:03 +02:00
Util.publishPomSettings ++ otherRootSettings ++ Formatting.sbtFilesSettings ++
Transform.conscriptSettings(bundledLauncherProj)
2014-12-18 05:38:10 +01:00
def otherRootSettings = Seq(
scripted <<= scriptedTask,
scriptedUnpublished <<= scriptedUnpublishedTask,
scriptedSource := (sourceDirectory in sbtProj).value / "sbt-test",
// scriptedPrescripted := { addSbtAlternateResolver _ },
scriptedLaunchOpts := List("-XX:MaxPermSize=256M", "-Xmx1G"),
publishAll := { val _ = (publishLocal).all(ScopeFilter(inAnyProject)).value },
publishLocalBinAll := { val _ = (publishLocalBin).all(ScopeFilter(inAnyProject)).value },
aggregate in bintrayRelease := false
) ++ inConfig(Scripted.RepoOverrideTest)(Seq(
scriptedPrescripted := { _ => () },
scriptedLaunchOpts := {
List("-XX:MaxPermSize=256M", "-Xmx1G", "-Dsbt.override.build.repos=true",
s"""-Dsbt.repository.config=${ scriptedSource.value / "repo.config" }""")
},
scripted <<= scriptedTask,
scriptedUnpublished <<= scriptedUnpublishedTask,
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
)
def fullDocSettings = Util.baseScalacOptions ++ Docs.settings ++ Sxr.settings ++ Seq(
scalacOptions += "-Ymacro-no-expand", // 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
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(
2015-09-14 09:27:22 +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(
2015-09-14 09:27:22 +02:00
inProjects(
testingProj, testAgentProj, taskProj,
2016-01-26 14:51:14 +01:00
scriptedSbtProj, scriptedPluginProj,
2015-06-20 20:21:16 +02:00
commandProj, mainSettingsProj, mainProj,
2016-04-29 08:39:34 +02:00
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("setupBuildScala211") { state =>
s"""set scalaVersion in ThisBuild := "$scala211" """ ::
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" ::
"so compile" ::
2014-12-18 23:40:20 +01:00
"so publishLocal" ::
"reload" ::
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" ::
"conscript-configs" ::
2014-12-18 23:40:20 +01:00
"so compile" ::
"so 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
}
)