Файли
openidea/src/platform/buildModel.ts
T
l0ng-ai dc74595bca feat(run): Tomcat before launch task list with Maven goal and Gradle task steps (#7294)
The Tomcat Server form's Before launch section only toggled one Build item. It now uses the same task list as other run configurations (BeforeLaunchTasks), with Tomcat's artifact Build as a removable, reorderable entry that existing configurations keep. Before launch also gains Run Maven Goal and Run Gradle Task steps that run through the build tools' existing execution and abort the launch on failure; BeforeLaunchTask gets an optional projectDir.

Fixes #7200
2026-12-02 04:19:59 +08:00

36 рядки
1.3 KiB
TypeScript

/**
* The open project's build model as the Maven / Gradle tool windows last loaded it, for the
* features that follow the build (run, Project view) without loading it again.
*/
import { create } from "zustand";
import type { BuildModel, BuildTool, RunConfig } from "./ipc";
export interface SharedBuildModel {
/** Project the model belongs to. */
root: string | null;
model: BuildModel | null;
/** Gradle tool window's "Offline" toggle. */
gradleOffline: boolean;
}
export const useBuildModel = create<SharedBuildModel>(() => ({ root: null, model: null, gradleOffline: false }));
export function buildToolProjectDirectory(root: string, dir: string): string {
const prefix = root.endsWith("/") ? root : `${root}/`;
return (dir === root || dir.startsWith(prefix) ? dir.slice(prefix.length) : dir) || ".";
}
type BuildToolLaunch = (tool: BuildTool, line: string, directory: string) => RunConfig | null;
let buildToolLaunch: BuildToolLaunch | undefined;
export function registerBuildToolLaunch(provider: BuildToolLaunch): () => void {
buildToolLaunch = provider;
return () => {
if (buildToolLaunch === provider) buildToolLaunch = undefined;
};
}
export function buildToolLaunchConfig(tool: BuildTool, line: string, directory: string): RunConfig | null {
return buildToolLaunch?.(tool, line, directory) ?? null;
}