Revert "Switch to varargs inThisBuild (+friends)"

This reverts commit ccf938c786.
This commit is contained in:
Eugene Yokota 2018-08-05 15:44:37 -04:00
parent 7c2ea0f374
commit eac7eef947
16 changed files with 234 additions and 210 deletions

View File

@ -135,7 +135,9 @@ object Defaults extends BuildCommon {
def buildCore: Seq[Setting[_]] = thisBuildCore ++ globalCore
def thisBuildCore: Seq[Setting[_]] =
inScope(GlobalScope.copy(project = Select(ThisBuild)))(
managedDirectory := baseDirectory.value / "lib_managed"
Seq(
managedDirectory := baseDirectory.value / "lib_managed"
)
)
private[sbt] lazy val globalCore: Seq[Setting[_]] = globalDefaults(
defaultTestTasks(test) ++ defaultTestTasks(testOnly) ++ defaultTestTasks(testQuick) ++ Seq(
@ -303,8 +305,10 @@ object Defaults extends BuildCommon {
def defaultTestTasks(key: Scoped): Seq[Setting[_]] =
inTask(key)(
tags := Seq(Tags.Test -> 1),
logBuffered := true
Seq(
tags := Seq(Tags.Test -> 1),
logBuffered := true
)
)
// TODO: This should be on the new default settings for a project.
@ -761,22 +765,26 @@ object Defaults extends BuildCommon {
lazy val ConfigGlobal: Scope = ConfigZero
def testTaskOptions(key: Scoped): Seq[Setting[_]] =
inTask(key)(
testListeners := {
TestLogger.make(
streams.value.log,
closeableTestLogger(
streamsManager.value,
test in resolvedScoped.value.scope,
logBuffered.value
)
) +:
new TestStatusReporter(succeededFile(streams.in(test).value.cacheDirectory)) +:
testListeners.in(TaskZero).value
},
testOptions := Tests.Listeners(testListeners.value) +: (testOptions in TaskZero).value,
testExecution := testExecutionTask(key).value
Seq(
testListeners := {
TestLogger.make(
streams.value.log,
closeableTestLogger(
streamsManager.value,
test in resolvedScoped.value.scope,
logBuffered.value
)
) +:
new TestStatusReporter(succeededFile(streams.in(test).value.cacheDirectory)) +:
testListeners.in(TaskZero).value
},
testOptions := Tests.Listeners(testListeners.value) +: (testOptions in TaskZero).value,
testExecution := testExecutionTask(key).value
)
) ++ inScope(GlobalScope)(
derive(testGrouping := singleTestGroupDefault.value)
Seq(
derive(testGrouping := singleTestGroupDefault.value)
)
)
private[this] def closeableTestLogger(manager: Streams, baseKey: Scoped, buffered: Boolean)(
@ -1049,24 +1057,28 @@ object Defaults extends BuildCommon {
lazy val packageConfig: Seq[Setting[_]] =
inTask(packageBin)(
packageOptions := {
val n = name.value
val ver = version.value
val org = organization.value
val orgName = organizationName.value
val main = mainClass.value
val old = packageOptions.value
Package.addSpecManifestAttributes(n, ver, orgName) +:
Package.addImplManifestAttributes(n, ver, homepage.value, org, orgName) +:
main.map(Package.MainClass.apply) ++: old
}
Seq(
packageOptions := {
val n = name.value
val ver = version.value
val org = organization.value
val orgName = organizationName.value
val main = mainClass.value
val old = packageOptions.value
Package.addSpecManifestAttributes(n, ver, orgName) +:
Package.addImplManifestAttributes(n, ver, homepage.value, org, orgName) +:
main.map(Package.MainClass.apply) ++: old
}
)
) ++
inTask(packageSrc)(
packageOptions := Package.addSpecManifestAttributes(
name.value,
version.value,
organizationName.value
) +: packageOptions.value
Seq(
packageOptions := Package.addSpecManifestAttributes(
name.value,
version.value,
organizationName.value
) +: packageOptions.value
)
) ++
packageTaskSettings(packageBin, packageBinMappings) ++
packageTaskSettings(packageSrc, packageSrcMappings) ++
@ -1154,12 +1166,14 @@ object Defaults extends BuildCommon {
def packageTaskSettings(key: TaskKey[File], mappingsTask: Initialize[Task[Seq[(File, String)]]]) =
inTask(key)(
key in TaskZero := packageTask.value,
packageConfiguration := packageConfigurationTask.value,
mappings := mappingsTask.value,
packagedArtifact := (artifact.value -> key.value),
artifact := artifactSetting.value,
artifactPath := artifactPathSetting(artifact).value
Seq(
key in TaskZero := packageTask.value,
packageConfiguration := packageConfigurationTask.value,
mappings := mappingsTask.value,
packagedArtifact := (artifact.value -> key.value),
artifact := artifactSetting.value,
artifactPath := artifactPathSetting(artifact).value
)
)
def packageTask: Initialize[Task[File]] =
@ -1367,49 +1381,51 @@ object Defaults extends BuildCommon {
def docTaskSettings(key: TaskKey[File] = doc): Seq[Setting[_]] =
inTask(key)(
apiMappings ++= {
val dependencyCp = dependencyClasspath.value
val log = streams.value.log
if (autoAPIMappings.value) APIMappings.extract(dependencyCp, log).toMap
else Map.empty[File, URL]
},
fileInputOptions := Seq("-doc-root-content", "-diagrams-dot-path"),
key in TaskZero := {
val s = streams.value
val cs: Compilers = compilers.value
val srcs = sources.value
val out = target.value
val sOpts = scalacOptions.value
val xapis = apiMappings.value
val hasScala = srcs.exists(_.name.endsWith(".scala"))
val hasJava = srcs.exists(_.name.endsWith(".java"))
val cp = data(dependencyClasspath.value).toList
val label = nameForSrc(configuration.value.name)
val fiOpts = fileInputOptions.value
val reporter = (compilerReporter in compile).value
(hasScala, hasJava) match {
case (true, _) =>
val options = sOpts ++ Opts.doc.externalAPI(xapis)
val runDoc = Doc.scaladoc(label, s.cacheStoreFactory sub "scala", cs.scalac match {
case ac: AnalyzingCompiler => ac.onArgs(exported(s, "scaladoc"))
}, fiOpts)
runDoc(srcs, cp, out, options, maxErrors.value, s.log)
case (_, true) =>
val javadoc =
sbt.inc.Doc.cachedJavadoc(label, s.cacheStoreFactory sub "java", cs.javaTools)
javadoc.run(
srcs.toList,
cp,
out,
javacOptions.value.toList,
IncToolOptionsUtil.defaultIncToolOptions(),
s.log,
reporter
)
case _ => () // do nothing
Seq(
apiMappings ++= {
val dependencyCp = dependencyClasspath.value
val log = streams.value.log
if (autoAPIMappings.value) APIMappings.extract(dependencyCp, log).toMap
else Map.empty[File, URL]
},
fileInputOptions := Seq("-doc-root-content", "-diagrams-dot-path"),
key in TaskZero := {
val s = streams.value
val cs: Compilers = compilers.value
val srcs = sources.value
val out = target.value
val sOpts = scalacOptions.value
val xapis = apiMappings.value
val hasScala = srcs.exists(_.name.endsWith(".scala"))
val hasJava = srcs.exists(_.name.endsWith(".java"))
val cp = data(dependencyClasspath.value).toList
val label = nameForSrc(configuration.value.name)
val fiOpts = fileInputOptions.value
val reporter = (compilerReporter in compile).value
(hasScala, hasJava) match {
case (true, _) =>
val options = sOpts ++ Opts.doc.externalAPI(xapis)
val runDoc = Doc.scaladoc(label, s.cacheStoreFactory sub "scala", cs.scalac match {
case ac: AnalyzingCompiler => ac.onArgs(exported(s, "scaladoc"))
}, fiOpts)
runDoc(srcs, cp, out, options, maxErrors.value, s.log)
case (_, true) =>
val javadoc =
sbt.inc.Doc.cachedJavadoc(label, s.cacheStoreFactory sub "java", cs.javaTools)
javadoc.run(
srcs.toList,
cp,
out,
javacOptions.value.toList,
IncToolOptionsUtil.defaultIncToolOptions(),
s.log,
reporter
)
case _ => () // do nothing
}
out
}
out
}
)
)
def mainBgRunTask = mainBgRunTaskForConfig(Select(Runtime))
@ -1710,13 +1726,15 @@ object Defaults extends BuildCommon {
// build.sbt is treated a Scala source of metabuild, so to enable deprecation flag on build.sbt we set the option here.
lazy val deprecationSettings: Seq[Setting[_]] =
inConfig(Compile)(
scalacOptions := {
val old = scalacOptions.value
val existing = old.toSet
val d = "-deprecation"
if (sbtPlugin.value && !existing(d)) d :: old.toList
else old
}
Seq(
scalacOptions := {
val old = scalacOptions.value
val existing = old.toSet
val d = "-deprecation"
if (sbtPlugin.value && !existing(d)) d :: old.toList
else old
}
)
)
}
object Classpaths {
@ -2258,82 +2276,84 @@ object Classpaths {
def sbtClassifiersTasks =
sbtClassifiersGlobalDefaults ++
inTask(updateSbtClassifiers)(
externalResolvers := {
val explicit = buildStructure.value
.units(thisProjectRef.value.build)
.unit
.plugins
.pluginData
.resolvers
explicit orElse bootRepositories(appConfiguration.value) getOrElse externalResolvers.value
},
ivyConfiguration := InlineIvyConfiguration(
paths = ivyPaths.value,
resolvers = externalResolvers.value.toVector,
otherResolvers = Vector.empty,
moduleConfigurations = Vector.empty,
lock = Option(lock(appConfiguration.value)),
checksums = checksums.value.toVector,
managedChecksums = false,
resolutionCacheDir = Some(crossTarget.value / "resolution-cache"),
updateOptions = UpdateOptions(),
log = streams.value.log
),
ivySbt := ivySbt0.value,
classifiersModule := classifiersModuleTask.value,
// Redefine scalaVersion and scalaBinaryVersion specifically for the dependency graph used for updateSbtClassifiers task.
// to fix https://github.com/sbt/sbt/issues/2686
scalaVersion := appConfiguration.value.provider.scalaProvider.version,
scalaBinaryVersion := binaryScalaVersion(scalaVersion.value),
scalaModuleInfo := {
Some(
ScalaModuleInfo(
scalaVersion.value,
scalaBinaryVersion.value,
Vector(),
checkExplicit = false,
filterImplicit = false,
overrideScalaVersion = true
).withScalaOrganization(scalaOrganization.value)
)
},
dependencyResolution := IvyDependencyResolution(ivyConfiguration.value),
updateSbtClassifiers in TaskGlobal := (Def.task {
val lm = dependencyResolution.value
val s = streams.value
val is = ivySbt.value
val mod = classifiersModule.value
val c = updateConfiguration.value
val app = appConfiguration.value
val srcTypes = sourceArtifactTypes.value
val docTypes = docArtifactTypes.value
val log = s.log
val out = is.withIvy(log)(_.getSettings.getDefaultIvyUserDir)
val uwConfig = (unresolvedWarningConfiguration in update).value
val depDir = dependencyCacheDirectory.value
val ivy = scalaModuleInfo.value
val st = state.value
withExcludes(out, mod.classifiers, lock(app)) {
excludes =>
// val noExplicitCheck = ivy.map(_.withCheckExplicit(false))
LibraryManagement.transitiveScratch(
lm,
"sbt",
GetClassifiersConfiguration(
mod,
excludes.toVector,
c.withArtifactFilter(c.artifactFilter.map(af => af.withInverted(!af.inverted))),
srcTypes.toVector,
docTypes.toVector
),
uwConfig,
log
) match {
case Left(_) => ???
case Right(ur) => ur
}
}
} tag (Tags.Update, Tags.Network)).value
Seq(
externalResolvers := {
val explicit = buildStructure.value
.units(thisProjectRef.value.build)
.unit
.plugins
.pluginData
.resolvers
explicit orElse bootRepositories(appConfiguration.value) getOrElse externalResolvers.value
},
ivyConfiguration := InlineIvyConfiguration(
paths = ivyPaths.value,
resolvers = externalResolvers.value.toVector,
otherResolvers = Vector.empty,
moduleConfigurations = Vector.empty,
lock = Option(lock(appConfiguration.value)),
checksums = checksums.value.toVector,
managedChecksums = false,
resolutionCacheDir = Some(crossTarget.value / "resolution-cache"),
updateOptions = UpdateOptions(),
log = streams.value.log
),
ivySbt := ivySbt0.value,
classifiersModule := classifiersModuleTask.value,
// Redefine scalaVersion and scalaBinaryVersion specifically for the dependency graph used for updateSbtClassifiers task.
// to fix https://github.com/sbt/sbt/issues/2686
scalaVersion := appConfiguration.value.provider.scalaProvider.version,
scalaBinaryVersion := binaryScalaVersion(scalaVersion.value),
scalaModuleInfo := {
Some(
ScalaModuleInfo(
scalaVersion.value,
scalaBinaryVersion.value,
Vector(),
checkExplicit = false,
filterImplicit = false,
overrideScalaVersion = true
).withScalaOrganization(scalaOrganization.value)
)
},
dependencyResolution := IvyDependencyResolution(ivyConfiguration.value),
updateSbtClassifiers in TaskGlobal := (Def.task {
val lm = dependencyResolution.value
val s = streams.value
val is = ivySbt.value
val mod = classifiersModule.value
val c = updateConfiguration.value
val app = appConfiguration.value
val srcTypes = sourceArtifactTypes.value
val docTypes = docArtifactTypes.value
val log = s.log
val out = is.withIvy(log)(_.getSettings.getDefaultIvyUserDir)
val uwConfig = (unresolvedWarningConfiguration in update).value
val depDir = dependencyCacheDirectory.value
val ivy = scalaModuleInfo.value
val st = state.value
withExcludes(out, mod.classifiers, lock(app)) {
excludes =>
// val noExplicitCheck = ivy.map(_.withCheckExplicit(false))
LibraryManagement.transitiveScratch(
lm,
"sbt",
GetClassifiersConfiguration(
mod,
excludes.toVector,
c.withArtifactFilter(c.artifactFilter.map(af => af.withInverted(!af.inverted))),
srcTypes.toVector,
docTypes.toVector
),
uwConfig,
log
) match {
case Left(_) => ???
case Right(ur) => ur
}
}
} tag (Tags.Update, Tags.Network)).value
)
) ++ Seq(bootIvyConfiguration := (ivyConfiguration in updateSbtClassifiers).value)
def classifiersModuleTask: Initialize[Task[GetClassifiersModule]] =
@ -3457,7 +3477,7 @@ trait BuildExtra extends BuildCommon with DefExtra {
* This is useful for reducing test:compile time when not running test.
*/
def noTestCompletion(config: Configuration = Test): Setting[_] =
inConfig(config)(definedTests := detectTests.value).head
inConfig(config)(Seq(definedTests := detectTests.value)).head
def filterKeys(ss: Seq[Setting[_]], transitive: Boolean = false)(
f: ScopedKey[_] => Boolean

View File

@ -47,7 +47,7 @@ private[sbt] object PluginCross {
val add = List(sbtVersion in GlobalScope in pluginCrossBuild :== version) ++
List(scalaVersion := scalaVersionSetting.value) ++
inScope(GlobalScope.copy(project = Select(currentRef)))(
scalaVersion := scalaVersionSetting.value
Seq(scalaVersion := scalaVersionSetting.value)
)
val cleared = session.mergeSettings.filterNot(crossExclude)
val newStructure = Load.reapply(cleared ++ add, structure, state.log)

View File

@ -106,11 +106,13 @@ object GlobalPlugin {
}
}
val globalPluginSettings = Project.inScope(Scope.GlobalScope in LocalRootProject)(
organization := SbtArtifacts.Organization,
onLoadMessage := Keys.baseDirectory("Loading global plugins from " + _).value,
name := "global-plugin",
sbtPlugin := true,
version := "0.0"
Seq(
organization := SbtArtifacts.Organization,
onLoadMessage := Keys.baseDirectory("Loading global plugins from " + _).value,
name := "global-plugin",
sbtPlugin := true,
version := "0.0"
)
)
}
final case class GlobalPluginData(

View File

@ -1189,20 +1189,22 @@ private[sbt] object Load {
/** These are the settings defined when loading a project "meta" build. */
val autoPluginSettings: Seq[Setting[_]] = inScope(GlobalScope in LocalRootProject)(
sbtPlugin :== true,
pluginData := {
val prod = (exportedProducts in Configurations.Runtime).value
val cp = (fullClasspath in Configurations.Runtime).value
val opts = (scalacOptions in Configurations.Compile).value
PluginData(
removeEntries(cp, prod),
prod,
Some(fullResolvers.value.toVector),
Some(update.value),
opts
)
},
onLoadMessage := ("Loading project definition from " + baseDirectory.value)
Seq(
sbtPlugin :== true,
pluginData := {
val prod = (exportedProducts in Configurations.Runtime).value
val cp = (fullClasspath in Configurations.Runtime).value
val opts = (scalacOptions in Configurations.Compile).value
PluginData(
removeEntries(cp, prod),
prod,
Some(fullResolvers.value.toVector),
Some(update.value),
opts
)
},
onLoadMessage := ("Loading project definition from " + baseDirectory.value)
)
)
private[this] def removeEntries(

View File

@ -1,6 +1,6 @@
inThisBuild(
inThisBuild(List(
crossScalaVersions := Seq("2.12.1", "2.11.8")
)
))
lazy val rootProj = (project in file("."))
.aggregate(libProj, fooPlugin)

View File

@ -22,7 +22,7 @@ x in subA in Compile := {
}
inConfig(Compile)(
inConfig(Compile)(Seq(
y in subB := {
// verify that the referenced key gets delegated
val xty = (x in Test in y).previous getOrElse 0 // 13
@ -31,7 +31,7 @@ inConfig(Compile)(
println(s"xcy=$xcy, xty=$xty")
xty * xcy
}
)
))
def parser = {
import complete.DefaultParsers._

View File

@ -4,7 +4,7 @@ dependencyOverrides in ThisBuild += "com.github.nscala-time" %% "nscala-time" %
lazy val root = (project in file("."))
.dependsOn(p1 % Compile)
.settings(
inThisBuild(
inThisBuild(List(
organizationName := "eed3si9n",
organizationHomepage := Some(url("http://example.com/")),
homepage := Some(url("https://github.com/example/example")),
@ -20,7 +20,7 @@ lazy val root = (project in file("."))
version := "0.3.1-SNAPSHOT",
description := "An HTTP client for Scala with Async Http Client underneath.",
licenses := Seq("Apache 2" -> new URL("http://www.apache.org/licenses/LICENSE-2.0.txt")),
),
)),
ivyPaths := IvyPaths(
(baseDirectory in ThisBuild).value,
Some((baseDirectory in LocalRootProject).value / "ivy-cache")

View File

@ -41,8 +41,8 @@ lazy val c = project.
lazy val root = (project in file(".")).
settings(commonSettings).
settings(inThisBuild(
settings(inThisBuild(Seq(
organization := "org.example",
version := "1.0-SNAPSHOT",
updateOptions := updateOptions.value.withCachedResolution(true)
))
)))

View File

@ -1,12 +1,12 @@
// https://github.com/sbt/sbt/issues/1710
// https://github.com/sbt/sbt/issues/1760
inThisBuild(
inThisBuild(Seq(
organization := "com.example",
version := "0.1.0",
scalaVersion := "2.10.4",
updateOptions := updateOptions.value.withCachedResolution(true)
)
))
def commonSettings: Seq[Def.Setting[_]] = Seq(
ivyPaths := IvyPaths((baseDirectory in ThisBuild).value, Some((baseDirectory in LocalRootProject).value / "ivy-cache")),

View File

@ -27,7 +27,7 @@ lazy val b = project.
lazy val root = (project in file(".")).
aggregate(a, b).
settings(inThisBuild(
settings(inThisBuild(Seq(
organization := "org.example",
version := "1.0",
updateOptions := updateOptions.value.withCachedResolution(true),
@ -45,4 +45,4 @@ lazy val root = (project in file(".")).
sys.error("commons-io NOT found when it should NOT be excluded")
}
}
))
)))

View File

@ -27,7 +27,7 @@ lazy val a = project.
lazy val root = (project in file(".")).
aggregate(a).
settings(inThisBuild(
settings(inThisBuild(Seq(
organization := "org.example",
version := "1.0",
updateOptions := updateOptions.value.withCachedResolution(true),
@ -49,4 +49,4 @@ lazy val root = (project in file(".")).
sys.error("junit NOT found when it should be included: " + atestcp.toString)
}
}
))
)))

View File

@ -2,12 +2,12 @@ lazy val p1 = (project in file("p1")).
settings(
checkTask(expectedMongo),
libraryDependencies += "org.mongodb" %% "casbah" % "2.4.1" pomOnly(),
inThisBuild(
inThisBuild(List(
organization := "org.example",
version := "1.0",
scalaVersion := "2.9.2",
autoScalaLibrary := false
)
))
)
lazy val p2 = (project in file("p2")).

View File

@ -1,12 +1,12 @@
lazy val root = (project in file(".")).
dependsOn(sub).
aggregate(sub).
settings(inThisBuild(
settings(inThisBuild(List(
organization := "A",
version := "1.0",
ivyPaths := baseDirectory( dir => IvyPaths(dir, Some(dir / "ivy" / "cache")) ).value,
externalResolvers := (baseDirectory map { base => Resolver.file("local", base / "ivy" / "local" asFile)(Resolver.ivyStylePatterns) :: Nil }).value
),
)),
mavenStyle,
interProject,
name := "Publish Test"

View File

@ -1,10 +1,10 @@
lazy val root = (project in file(".")).
settings(inThisBuild(
settings(inThisBuild(List(
organization := "A",
version := "1.0",
ivyPaths := baseDirectory( dir => IvyPaths(dir, Some(dir / "ivy" / "cache")) ).value,
externalResolvers := (baseDirectory map { base => Resolver.file("local", base / "ivy" / "local" asFile)(Resolver.ivyStylePatterns) :: Nil }).value
),
)),
mavenStyle,
name := "Retrieve Test",
libraryDependencies := (publishMavenStyle { style => if(style) mavenStyleDependencies else ivyStyleDependencies }).value

View File

@ -23,7 +23,7 @@ globalDepE in Global := "globalE"
// ---------------- Derived settings
// verify that deriving is transitive
inScope(GlobalScope)(
inScope(GlobalScope)(Seq(
Def.derive(customA := customB.value + "-a"),
Def.derive(customB := thisProject.value.id + "-b"),
// verify that a setting with multiple triggers still only gets added once
@ -36,7 +36,7 @@ inScope(GlobalScope)(
// if customE were added in Global because of name, there would be an error
// because description wouldn't be found
Def.derive(customE := globalDepE.value + "-" + projectDepE.value)
)
))
// ---------------- Projects

View File

@ -1,7 +1,7 @@
scalaVersion in ThisBuild := "2.11.8"
concurrentRestrictions in Global := Seq(Tags.limitAll(4))
libraryDependencies += "org.specs2" %% "specs2-core" % "3.8.4" % Test
inConfig(Test)(
inConfig(Test)(Seq(
testGrouping := {
val home = javaHome.value
val strategy = outputStrategy.value
@ -22,4 +22,4 @@ inConfig(Test)(
))}
},
TaskKey[Unit]("test-failure") := test.failure.value
)
))