Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

report sbt's build progress #5788

Merged
merged 1 commit into from
Oct 26, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -215,24 +215,37 @@ final class ForwardingMetalsBuildClient(

@JsonNotification("build/taskProgress")
def buildTaskProgress(params: TaskProgressParams): Unit = {
def buildTargetFromParams: Option[BuildTargetIdentifier] =
for {
data <- Option(params.getData).collect { case o: JsonObject =>
o
}
targetElement <- Option(data.get("target"))
if targetElement.isJsonObject
target = targetElement.getAsJsonObject
uriElement <- Option(target.get("uri"))
if uriElement.isJsonPrimitive
uri = uriElement.getAsJsonPrimitive
if uri.isString
} yield new BuildTargetIdentifier(uri.getAsString)

params.getDataKind match {
case "bloop-progress" =>
for {
data <- Option(params.getData).collect { case o: JsonObject =>
o
}
targetElement <- Option(data.get("target"))
if targetElement.isJsonObject
target = targetElement.getAsJsonObject
uriElement <- Option(target.get("uri"))
if uriElement.isJsonPrimitive
uri = uriElement.getAsJsonPrimitive
if uri.isString
buildTarget = new BuildTargetIdentifier(uri.getAsString)
buildTarget <- buildTargetFromParams
report <- compilations.get(buildTarget)
} yield {
report.progress.update(params.getProgress, params.getTotal)
}
case "compile-progress" =>
// "compile-progress" is from sbt, however its progress field is actually a percentage,
// so we should fix the total to 100.
adpi2 marked this conversation as resolved.
Show resolved Hide resolved
for {
buildTarget <- buildTargetFromParams
report <- compilations.get(buildTarget)
} yield {
report.progress.update(params.getProgress, newTotal = 100)
}
case _ =>
}
}
Expand Down