diff --git a/src/main/java/com/google/devtools/build/lib/bazel/commands/ModCommand.java b/src/main/java/com/google/devtools/build/lib/bazel/commands/ModCommand.java index 7f4b9676f1fbb9..77f3ddd5e0dc6f 100644 --- a/src/main/java/com/google/devtools/build/lib/bazel/commands/ModCommand.java +++ b/src/main/java/com/google/devtools/build/lib/bazel/commands/ModCommand.java @@ -27,6 +27,8 @@ import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSortedSet; import com.google.common.collect.Iterables; +import com.google.devtools.build.lib.analysis.NoBuildEvent; +import com.google.devtools.build.lib.analysis.NoBuildRequestFinishedEvent; import com.google.devtools.build.lib.bazel.bzlmod.BazelDepGraphValue; import com.google.devtools.build.lib.bazel.bzlmod.BazelModuleInspectorValue; import com.google.devtools.build.lib.bazel.bzlmod.BazelModuleInspectorValue.AugmentedModule; @@ -106,6 +108,23 @@ public void editOptions(OptionsParser optionsParser) { @Override public BlazeCommandResult exec(CommandEnvironment env, OptionsParsingResult options) { + env.getEventBus() + .post( + new NoBuildEvent( + env.getCommandName(), + env.getCommandStartTime(), + /* separateFinishedEvent= */ true, + /* showProgress= */ true, + /* id= */ null)); + BlazeCommandResult result = execInternal(env, options); + env.getEventBus() + .post( + new NoBuildRequestFinishedEvent( + result.getExitCode(), env.getRuntime().getClock().currentTimeMillis())); + return result; + } + + private BlazeCommandResult execInternal(CommandEnvironment env, OptionsParsingResult options) { BazelDepGraphValue depGraphValue; BazelModuleInspectorValue moduleInspector; diff --git a/src/main/java/com/google/devtools/build/lib/runtime/UiEventHandler.java b/src/main/java/com/google/devtools/build/lib/runtime/UiEventHandler.java index 9b0f54f7b8ec51..17eca133cf549b 100644 --- a/src/main/java/com/google/devtools/build/lib/runtime/UiEventHandler.java +++ b/src/main/java/com/google/devtools/build/lib/runtime/UiEventHandler.java @@ -607,6 +607,9 @@ private void completeBuild() { return; } buildRunning = false; + // Have to set this, otherwise there's a lingering "checking cached actions" message for the + // `mod` command, which doesn't even run any actions. + stateTracker.setBuildComplete(); } stopUpdateThread(); synchronized (this) { diff --git a/src/main/java/com/google/devtools/build/lib/runtime/UiStateTracker.java b/src/main/java/com/google/devtools/build/lib/runtime/UiStateTracker.java index dac8c42ed3b7bc..9af1f028947549 100644 --- a/src/main/java/com/google/devtools/build/lib/runtime/UiStateTracker.java +++ b/src/main/java/com/google/devtools/build/lib/runtime/UiStateTracker.java @@ -71,7 +71,7 @@ import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.atomic.AtomicInteger; import javax.annotation.Nullable; -import javax.annotation.concurrent.GuardedBy; +import javax.annotation.concurrent.GuardedBy; import javax.annotation.concurrent.ThreadSafe; /** Tracks state for the UI. */ @@ -465,8 +465,7 @@ synchronized void progressReceiverAvailable(ExecutionProgressReceiverAvailableEv } void buildComplete(BuildCompleteEvent event) { - buildComplete = true; - buildCompleteAt = Instant.ofEpochMilli(clock.currentTimeMillis()); + setBuildComplete(); if (event.getResult().getSuccess()) { status = "INFO"; @@ -500,6 +499,11 @@ protected boolean buildCompleted() { return buildComplete; } + public void setBuildComplete() { + buildComplete = true; + buildCompleteAt = Instant.ofEpochMilli(clock.currentTimeMillis()); + } + synchronized void downloadProgress(FetchProgress event) { String url = event.getResourceIdentifier(); if (event.isFinished()) {