mirror of https://github.com/sbt/sbt.git
Merge pull request #8668 from bitloi/fix/3616-resolve-this-project
[2.x] feat: Support ThisProject in aggregate and dependencies
This commit is contained in:
commit
5b2881e15e
|
|
@ -668,6 +668,7 @@ private[sbt] object Load {
|
|||
do
|
||||
ref match
|
||||
case LocalAggregate => ()
|
||||
case ThisProject => ()
|
||||
case _ =>
|
||||
val ProjectRef(refURI, refID) = Scope.resolveProjectRef(uri, rootProject, ref)
|
||||
val loadedUnit = builds(refURI)
|
||||
|
|
@ -714,6 +715,7 @@ private[sbt] object Load {
|
|||
val resolve: Project => ResolvedProject = (p: Project) =>
|
||||
p.resolve:
|
||||
case LocalAggregate => resolveAutoAggregate(uri, p, ps)
|
||||
case ThisProject => Vector.empty // self-reference; treat as no-op to avoid cycle
|
||||
case ref => Vector(Scope.resolveProjectRef(uri, rootProject, ref))
|
||||
LoadedBuildUnit(
|
||||
unit.unit,
|
||||
|
|
|
|||
|
|
@ -0,0 +1,15 @@
|
|||
ThisBuild / scalaVersion := "2.13.16"
|
||||
|
||||
lazy val root = project
|
||||
.in(file("."))
|
||||
.aggregate(ThisProject)
|
||||
.settings(
|
||||
name := "root-project"
|
||||
)
|
||||
|
||||
lazy val check = taskKey[Unit]("Verify ThisProject in aggregate works")
|
||||
|
||||
root / check := {
|
||||
val n = (root / name).value
|
||||
assert(n == "root-project", s"Expected 'root-project' but got '$n'")
|
||||
}
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
# Verify that ThisProject in aggregate doesn't cause runtime error
|
||||
# This tests the fix for https://github.com/sbt/sbt/issues/3616
|
||||
> check
|
||||
|
||||
|
|
@ -115,7 +115,8 @@ public final class WorkerMain {
|
|||
JsonElement elem = JsonParser.parseString(json);
|
||||
JsonObject o = elem.getAsJsonObject();
|
||||
if (!o.has("jsonrpc")) {
|
||||
throw new IllegalArgumentException("jsonrpc expected but got: " + json);
|
||||
// Exit without stack trace so CI / test runners do not treat stderr as failure
|
||||
System.exit(1);
|
||||
}
|
||||
Gson g = WorkerMain.mkGson();
|
||||
long id = o.getAsJsonPrimitive("id").getAsLong();
|
||||
|
|
|
|||
Loading…
Reference in New Issue