feat(run): stream the Java before-launch build to the status bar and Build window (#5801)

The before-launch build of a Java Run / Debug launch now streams its output, messages and progress: java_resolve_launch takes a BuildEvent channel, launches joining a shared Maven build receive its events, and the frontend shows a cancellable status bar task, the build's commands in the run console and the full output in the Build tool window.

Closes #5780
Refs #4078
Цей коміт міститься в:
l0ng-ai authored and GitHub committed 2026-11-25 14:36:43 +08:00
1 джерело 8122127dde
коміт 9be4803462
28 files changed
+406 -67

No files matched your search

+37 -2
Переглянути файл
@@ -4,10 +4,13 @@
* `${classpath}` (or `${testClasspath}`) and the `java` launcher are resolved
* through jdtls when the configuration starts.
*/
import { Channel } from "@tauri-apps/api/core";
import {
call,
commands,
IpcError,
isCancelled,
type BuildEvent,
type BuildPolicy,
type JavaLaunchInfo,
type JunitLaunch,
@@ -247,6 +250,34 @@ export interface JavaPreparation {
policy?: BuildPolicy;
/** Saves open documents first, as IDEA's Before launch does. */
saveAll?: () => Promise<void>;
/** Follows the build while it runs (status bar, Build tool window); see `followLaunchBuild`. */
build?: JavaBuildFollower;
}
/** Receives the events of a launch's build as it runs, then its outcome. */
export interface JavaBuildFollower {
onEvent(e: BuildEvent): void;
finish(status: "success" | "failed" | "cancelled"): void;
}
/** `javaResolveLaunch`, streaming the build's events to `build`, which then gets the outcome. */
export async function resolveJavaLaunch(
module: string,
test: boolean,
policy: BuildPolicy,
request: RequestId,
build?: JavaBuildFollower,
): Promise<JavaLaunchInfo> {
const channel = new Channel<BuildEvent>();
channel.onmessage = (e) => build?.onEvent(e);
try {
const info = await call(commands.javaResolveLaunch(module, test, policy, request, channel));
build?.finish(info.build === "failed" ? "failed" : info.build === "cancelled" ? "cancelled" : "success");
return info;
} catch (e) {
build?.finish(isCancelled(e) ? "cancelled" : "failed");
throw e;
}
}
/** The build the launch would do: the configuration's policy, else incremental. */
@@ -268,8 +299,12 @@ export async function prepareJavaLaunch(config: RunConfig, preparation: JavaPrep
const started = performance.now();
const module = await prepareJavaModule(config, preparation.saveAll, signal);
const moduleMs = performance.now() - started;
const info = await call(
commands.javaResolveLaunch(module, parsed.classpath === "test", policy, preparation.request),
const info = await resolveJavaLaunch(
module,
parsed.classpath === "test",
policy,
preparation.request,
preparation.build,
).catch((error: unknown) => {
if (error instanceof IpcError && error.data?.type === "javaBuildProblems") {
const problems = error.data.problems.join("; ");