Internal usage of inputTaskDyn

This commit is contained in:
Adrien Piquerez 2025-02-07 12:02:16 +01:00
parent 11cd58daa7
commit 711df2cbf2
2 changed files with 22 additions and 23 deletions

View File

@ -4705,22 +4705,20 @@ trait BuildExtra extends BuildCommon with DefExtra {
baseArguments: String*
): Vector[Setting[?]] = {
Vector(
scoped := Def
.input(_ => Def.spaceDelimited())
.flatMapTask { result =>
initScoped(
scoped.scopedKey,
ClassLoaders.runner.mapReferenced(Project.mapScope(_.rescope(config))),
).zipWith(Def.task {
((config / fullClasspath).value, streams.value, fileConverter.value, result)
}) { (rTask, t) =>
(t, rTask) mapN { case ((cp, s, converter, args), r) =>
given FileConverter = converter
r.run(mainClass, cp.files, baseArguments ++ args, s.log).get
}
scoped := Def.inputTaskDyn {
val result = Def.spaceDelimited().parsed
initScoped(
scoped.scopedKey,
ClassLoaders.runner.mapReferenced(Project.mapScope(_.rescope(config))),
).zipWith(Def.task {
((config / fullClasspath).value, streams.value, fileConverter.value, result)
}) { (rTask, t) =>
(t, rTask) mapN { case ((cp, s, converter, args), r) =>
given FileConverter = converter
r.run(mainClass, cp.files, baseArguments ++ args, s.log).get
}
}
.evaluated
}.evaluated
) ++ inTask(scoped)((config / forkOptions) := forkOptionsTask.value)
}

View File

@ -747,13 +747,12 @@ object BuildServerProtocol {
private inline def bspInputTask[T](
inline taskImpl: (BspFullWorkspace, ScopeFilter) => T
): Def.Initialize[InputTask[T]] =
Def
.input(_ => targetIdentifierParser)
.flatMapTask { targets =>
val workspace: BspFullWorkspace = bspFullWorkspace.value.filter(targets)
val filter = ScopeFilter.in(workspace.scopes.values.toList)
Def.task(taskImpl(workspace, filter))
}
Def.inputTaskDyn {
val targets = targetIdentifierParser.parsed
val workspace: BspFullWorkspace = bspFullWorkspace.value.filter(targets)
val filter = ScopeFilter.in(workspace.scopes.values.toList)
Def.task(taskImpl(workspace, filter))
}
private def jvmEnvironmentItem(): Initialize[Task[JvmEnvironmentItem]] = Def.task {
val target = Keys.bspTargetIdentifier.value
@ -866,7 +865,8 @@ object BuildServerProtocol {
.map(JsonParser.parseFromString)
private def bspRunTask: Def.Initialize[InputTask[Unit]] =
Def.input(_ => jsonParser).flatMapTask { json =>
Def.inputTaskDyn {
val json = jsonParser.parsed
val runParams = json.flatMap(Converter.fromJson[RunParams]).get
val defaultClass = Keys.mainClass.value
val defaultJvmOptions = Keys.javaOptions.value
@ -909,7 +909,8 @@ object BuildServerProtocol {
}
private def bspTestTask: Def.Initialize[InputTask[Unit]] =
Def.input(_ => jsonParser).flatMapTask { json =>
Def.inputTaskDyn {
val json = jsonParser.parsed
val testParams = json.flatMap(Converter.fromJson[TestParams]).get
val workspace = bspFullWorkspace.value