mirror of https://github.com/sbt/sbt.git
Merge pull request #7519 from adpi2/sbt2-fix-todo
[sbt2] Reactivate checkTargets in Load
This commit is contained in:
commit
40ba7e9a27
|
|
@ -357,31 +357,6 @@ trait ProjectExtra extends Scoped.Syntax:
|
|||
def setCond[T](key: AttributeKey[T], vopt: Option[T], attributes: AttributeMap): AttributeMap =
|
||||
attributes.setCond(key, vopt)
|
||||
|
||||
private[sbt] def checkTargets(data: Settings[Scope]): Option[String] =
|
||||
val dups = overlappingTargets(allTargets(data))
|
||||
if (dups.isEmpty) None
|
||||
else {
|
||||
val dupStrs = dups map { case (dir, scopes) =>
|
||||
s"${dir.getAbsolutePath}:\n\t${scopes.mkString("\n\t")}"
|
||||
}
|
||||
Some(s"Overlapping output directories:${dupStrs.mkString}")
|
||||
}
|
||||
|
||||
private[this] def overlappingTargets(
|
||||
targets: Seq[(ProjectRef, File)]
|
||||
): Map[File, Seq[ProjectRef]] =
|
||||
targets.groupBy(_._2).view.filter(_._2.size > 1).mapValues(_.map(_._1)).toMap
|
||||
|
||||
private[this] def allTargets(data: Settings[Scope]): Seq[(ProjectRef, File)] = {
|
||||
import ScopeFilter._
|
||||
val allProjects = ScopeFilter(Make.inAnyProject)
|
||||
val targetAndRef = Def.setting { (Keys.thisProjectRef.value, Keys.target.value) }
|
||||
new SettingKeyAll(Def.optional(targetAndRef)(identity))
|
||||
.all(allProjects)
|
||||
.evaluate(data)
|
||||
.flatMap(x => x)
|
||||
}
|
||||
|
||||
private[sbt] def equalKeys(a: ScopedKey[_], b: ScopedKey[_], mask: ScopeMask): Boolean =
|
||||
a.key == b.key && Scope.equal(a.scope, b.scope, mask)
|
||||
|
||||
|
|
|
|||
|
|
@ -283,8 +283,7 @@ private[sbt] object Load {
|
|||
)
|
||||
}
|
||||
|
||||
// todo: fix this
|
||||
// Project.checkTargets(data) foreach sys.error
|
||||
checkTargets(data).foreach(sys.error)
|
||||
val index = timed("Load.apply: structureIndex", log) {
|
||||
structureIndex(data, settings, loaded.extra(data), projects)
|
||||
}
|
||||
|
|
@ -304,6 +303,29 @@ private[sbt] object Load {
|
|||
(rootEval, bs)
|
||||
}
|
||||
|
||||
private def checkTargets(data: Settings[Scope]): Option[String] =
|
||||
val dups = overlappingTargets(allTargets(data))
|
||||
if (dups.isEmpty) None
|
||||
else {
|
||||
val dupStr = dups.map { case (dir, scopes) =>
|
||||
s"${dir.getAbsolutePath}:\n\t${scopes.mkString("\n\t")}"
|
||||
}.mkString
|
||||
Some(s"Overlapping output directories:$dupStr")
|
||||
}
|
||||
|
||||
private def overlappingTargets(targets: Seq[(ProjectRef, File)]): Map[File, Seq[ProjectRef]] =
|
||||
targets.groupBy(_._2).view.filter(_._2.size > 1).mapValues(_.map(_._1)).toMap
|
||||
|
||||
private def allTargets(data: Settings[Scope]): Seq[(ProjectRef, File)] = {
|
||||
import ScopeFilter._
|
||||
val allProjects = ScopeFilter(Make.inAnyProject)
|
||||
val targetAndRef = Def.setting { (Keys.thisProjectRef.value, Keys.target.value) }
|
||||
new SettingKeyAll(Def.optional(targetAndRef)(identity))
|
||||
.all(allProjects)
|
||||
.evaluate(data)
|
||||
.flatMap(x => x)
|
||||
}
|
||||
|
||||
// map dependencies on the special tasks:
|
||||
// 1. the scope of 'streams' is the same as the defining key and has the task axis set to the defining key
|
||||
// 2. the defining key is stored on constructed tasks: used for error reporting among other things
|
||||
|
|
|
|||
|
|
@ -13,22 +13,13 @@ def commonSettings: Seq[Def.Setting[_]] =
|
|||
resolvers += MavenCache("local-maven", (LocalRootProject / target).value / "local-maven"),
|
||||
)
|
||||
|
||||
lazy val root = (project in file("."))
|
||||
.settings(commonSettings)
|
||||
|
||||
val `v1-0-0` = (project in file("v1.0.0"))
|
||||
val semverSpecTest = project
|
||||
.settings(commonSettings)
|
||||
.settings(
|
||||
name := "semver-spec-test",
|
||||
version := "1.0.0",
|
||||
)
|
||||
|
||||
val `v1-1-0` = (project in file("v1.1.0"))
|
||||
.settings(commonSettings)
|
||||
.settings(
|
||||
name := "semver-spec-test",
|
||||
version := "1.1.0",
|
||||
)
|
||||
|
||||
val middle = project
|
||||
.settings(commonSettings)
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
> v1-0-0/publish
|
||||
> v1-1-0/publish
|
||||
> semverSpecTest/publish
|
||||
> set semverSpecTest/version := "1.1.0"
|
||||
> semverSpecTest/publish
|
||||
> middle/publish
|
||||
|
||||
> use/check
|
||||
|
|
|
|||
|
|
@ -1,3 +0,0 @@
|
|||
package example
|
||||
|
||||
trait Foo {}
|
||||
|
|
@ -1,3 +0,0 @@
|
|||
package example
|
||||
|
||||
trait Foo {}
|
||||
Loading…
Reference in New Issue