sbt/build.sbt

356 lines
13 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 Scripted._
import Sxr.sxr
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",
2015-08-19 13:12:14 +02:00
bintrayOrganization := Some(if (publishStatus.value == "releases") "typesafe" else "sbt"),
bintrayRepository := s"ivy-${publishStatus.value}",
bintrayPackage := "sbt",
2015-09-11 11:00:34 +02:00
bintrayReleaseOnPublish := false,
resolvers += Resolver.mavenLocal
2015-08-19 13:12:14 +02:00
))
2015-02-06 19:48:12 +01:00
2014-12-18 05:38:10 +01:00
def commonSettings: Seq[Setting[_]] = Seq(
scalaVersion := scala210,
2014-12-18 05:38:10 +01:00
publishArtifact in packageDoc := false,
publishMavenStyle := false,
componentID := None,
crossPaths := false,
resolvers += Resolver.typesafeIvyRepo("releases"),
resolvers += Resolver.sonatypeRepo("snapshots"),
2015-09-14 09:27:22 +02:00
resolvers += Resolver.bintrayRepo("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),
2015-04-20 07:20:23 +02:00
crossScalaVersions := Seq(scala210),
bintrayPackage := (bintrayPackage in ThisBuild).value,
bintrayRepository := (bintrayRepository in ThisBuild).value
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(".")).
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",
publishArtifact in packageSrc := false,
autoScalaLibrary := 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,
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
lazy val taskProj = (project in tasksPath).
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.
lazy val stdTaskProj = (project in tasksPath / "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, (utilLogging % Test).classifier("tests"), compilerClasspath)
2014-12-18 05:38:10 +01:00
)
lazy val scriptedBaseProj = (project in scriptedPath / "base").
settings(
testedBaseSettings,
2014-12-18 05:38:10 +01:00
name := "Scripted Framework",
2015-09-14 09:27:22 +02:00
libraryDependencies ++= scalaParsers.value ++ Seq(sbtIO)
2014-12-18 05:38:10 +01:00
)
lazy val scriptedSbtProj = (project in scriptedPath / "sbt").
2015-09-11 11:00:34 +02:00
dependsOn(scriptedBaseProj, 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",
sbtIO, utilLogging, compilerInterface)
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.
lazy val actionsProj = (project in mainPath / "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,
incrementalcompiler, compilerIvyIntegration, compilerInterface,
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
lazy val commandProj = (project in mainPath / "command").
settings(
testedBaseSettings,
name := "Command",
2015-09-14 09:27:22 +02:00
libraryDependencies ++= Seq(launcherInterface, compilerInterface,
sbtIO, utilLogging, utilCompletion, compilerClasspath)
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
lazy val mainSettingsProj = (project in mainPath / "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",
2015-09-14 09:27:22 +02:00
libraryDependencies ++= Seq(sbinary, utilApplyMacro, compilerInterface, utilRelation,
utilLogging, sbtIO, utilCompletion, compilerClasspath, libraryManagement)
2014-12-18 05:38:10 +01:00
)
// The main integration project for sbt. It brings all of the Projsystems together, configures them, and provides for overriding conventions.
lazy val mainProj = (project in mainPath).
2015-09-14 09:27:22 +02:00
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,
sbtIO, utilLogging, utilLogic, libraryManagement, incrementalcompilerCompile)
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)
lazy val sbtProj = (project in sbtPath).
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",
libraryDependencies ++= Seq(compilerBrdige)
2014-12-18 05:38:10 +01:00
)
lazy val mavenResolverPluginProj = (project in file("sbt-maven-resolver")).
2015-09-14 09:27:22 +02:00
dependsOn(sbtProj).
settings(
baseSettings,
name := "sbt-maven-resolver",
2015-09-11 11:00:34 +02:00
libraryDependencies ++= aetherLibs ++ Seq(utilTesting % Test, (libraryManagement % Test).classifier("tests"), libraryManagement % Test),
sbtPlugin := true
)
2015-07-10 11:53:48 +02:00
def scriptedTask: Def.Initialize[InputTask[Unit]] = Def.inputTask {
2015-01-13 04:01:16 +01:00
val result = scriptedSource(dir => (s: State) => scriptedParser(dir)).parsed
publishAll.value
doScripted((sbtLaunchJar in bundledLauncherProj).value, (fullClasspath in scriptedSbtProj in Test).value,
2015-01-13 04:01:16 +01:00
(scalaInstance in scriptedSbtProj).value, scriptedSource.value, result, scriptedPrescripted.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 {
2015-01-13 04:01:16 +01:00
val result = scriptedSource(dir => (s: State) => scriptedParser(dir)).parsed
doScripted((sbtLaunchJar in bundledLauncherProj).value, (fullClasspath in scriptedSbtProj in Test).value,
2015-01-13 04:01:16 +01:00
(scalaInstance in scriptedSbtProj).value, scriptedSource.value, result, scriptedPrescripted.value)
2014-12-18 05:38:10 +01:00
}
lazy val publishAll = TaskKey[Unit]("publish-all")
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,
2014-12-18 05:38:10 +01:00
scriptedBaseProj, scriptedSbtProj, scriptedPluginProj,
actionsProj, commandProj, mainSettingsProj, mainProj, sbtProj, bundledLauncherProj, mavenResolverPluginProj)
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(
2015-01-13 04:01:16 +01:00
Scripted.scriptedPrescripted := { _ => },
2014-12-18 05:38:10 +01:00
Scripted.scripted <<= scriptedTask,
Scripted.scriptedUnpublished <<= scriptedUnpublishedTask,
2015-07-10 11:53:48 +02:00
Scripted.scriptedSource := (sourceDirectory in sbtProj).value / "sbt-test",
publishAll := {
2015-02-03 04:44:02 +01:00
val _ = (publishLocal).all(ScopeFilter(inAnyProject)).value
},
aggregate in bintrayRelease := false
2015-01-13 04:01:16 +01:00
) ++ inConfig(Scripted.MavenResolverPluginTest)(Seq(
Scripted.scripted <<= scriptedTask,
Scripted.scriptedUnpublished <<= scriptedUnpublishedTask,
Scripted.scriptedPrescripted := { f =>
val inj = f / "project" / "maven.sbt"
if (!inj.exists) {
IO.write(inj, "addMavenResolverPlugin")
2015-01-13 04:01:16 +01:00
// sLog.value.info(s"""Injected project/maven.sbt to $f""")
}
}
))
lazy val docProjects: ScopeFilter = ScopeFilter(
inAnyProject -- inProjects(sbtRoot, sbtProj, scriptedBaseProj, scriptedSbtProj, scriptedPluginProj, mavenResolverPluginProj),
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
)
/* Nested Projproject paths */
def sbtPath = file("sbt")
def tasksPath = file("tasks")
def launchPath = file("launch")
def mainPath = file("main")
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,
2015-06-20 20:21:16 +02:00
scriptedBaseProj, scriptedSbtProj, scriptedPluginProj,
commandProj, mainSettingsProj, mainProj,
sbtProj, mavenResolverPluginProj),
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
},
// This is invoked by Travis
commands += Command.command("checkBuildScala211") { state =>
s"++ $scala211" ::
// First compile everything before attempting to test
"all compile test:compile" ::
// Now run known working tests.
safeUnitTests.key.label ::
state
},
safeUnitTests := {
test.all(safeProjects).value
},
2015-06-20 20:21:16 +02:00
otherUnitTests := {
test.all(otherProjects)
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.5.
*
* Second is the fact that all subprojects are released with crossPaths
* turned off for the sbt's Scala version 2.10.5, 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
}
)