From da3db5cbd60b95fbccccfdbda92de1557b994bdc Mon Sep 17 00:00:00 2001 From: arookieofc Date: Tue, 10 Nov 2026 17:29:54 +0800 Subject: [PATCH] fix(build): scope Build Artifacts to the active file's module (#2491) * fix(build): scope Build Artifacts to the active file's module Build Artifacts always packaged the whole reactor (all 57 modules in the reporter's project) because the frontend passed a null file. Route it through moduleTarget like Build Module does, so Maven runs '-pl -am package' and Gradle runs ':assemble'; with no active file it still falls back to the whole project. Backend already supported module-scoped artifacts for Maven and Gradle, no Rust change. Refs #2476 * fix(build): translate the module-scoped Build Artifacts description The new action description needs a zh catalog entry (the only complete locale) and the old text must go from every catalog (the stale-entry check covers all locales); otherwise textCatalog.test.ts fails. Refs #2476 --- src/features/build/build.test.tsx | 24 ++++++++++++++++++++++++ src/features/build/index.ts | 6 +++--- src/platform/locales/text/es.json | 1 - src/platform/locales/text/fr.json | 1 - src/platform/locales/text/ko.json | 1 - src/platform/locales/text/pl.json | 1 - src/platform/locales/text/pt.json | 1 - src/platform/locales/text/zh.json | 2 +- 8 files changed, 28 insertions(+), 9 deletions(-) diff --git a/src/features/build/build.test.tsx b/src/features/build/build.test.tsx index cfcd1ffcd..3f628c646 100644 --- a/src/features/build/build.test.tsx +++ b/src/features/build/build.test.tsx @@ -324,6 +324,30 @@ describe("build feature", () => { }); }); + it("scopes Build Artifacts to the active file's module, or the whole project without one", async () => { + provideEditorService({ + openFile, + saveAll: () => Promise.resolve(), + activePath: () => "/p/core/src/A.java", + } as unknown as EditorService); + await executeAction("build.buildArtifacts", { activate: false }); + expect(fake.calls.at(-1)).toMatchObject({ kind: "artifacts", file: "/p/core/src/A.java" }); + await act(async () => { + fake.resolve(result([], true)); + }); + + provideEditorService({ + openFile, + saveAll: () => Promise.resolve(), + activePath: () => null, + } as unknown as EditorService); + await executeAction("build.buildArtifacts", { activate: false }); + expect(fake.calls.at(-1)).toMatchObject({ kind: "artifacts", file: null }); + await act(async () => { + fake.resolve(result([], true)); + }); + }); + it("starts a build without a workbench", async () => { show.mockImplementation(() => { throw new Error("No workbench"); diff --git a/src/features/build/index.ts b/src/features/build/index.ts index ff1aaa3cc..bb800e6c8 100644 --- a/src/features/build/index.ts +++ b/src/features/build/index.ts @@ -102,14 +102,14 @@ export function activate(): () => void { { id: "build.buildArtifacts", title: "Build Artifacts", - description: "Packages the project (mvn package, gradle assemble, cargo build --release, npm run build)", + description: "Packages the current module's artifacts, or the whole project when no file is active", category: "Build", when: WHEN, - keywords: ["package", "assemble", "jar", "release"], + keywords: ["package", "assemble", "jar", "release", "module"], run: ({ arg }) => { const options = typeof arg === "object" && arg !== null ? arg : {}; const activate = !("activate" in options && options.activate === false); - const build = startBuild("artifacts", null, activate); + const build = startBuild("artifacts", moduleTarget(arg), activate); if ("wait" in options && options.wait === true) return build.then(() => undefined); }, }, diff --git a/src/platform/locales/text/es.json b/src/platform/locales/text/es.json index 5999bb7f1..b432c8d49 100644 --- a/src/platform/locales/text/es.json +++ b/src/platform/locales/text/es.json @@ -1476,7 +1476,6 @@ "Package manager": "Administrador de paquetes", "Package to install": "Paquete a instalar", "Packages": "Paquetes", - "Packages the project (mvn package, gradle assemble, cargo build --release, npm run build)": "Empaqueta el proyecto (mvn package, gradle assemble, cargo build --release, npm run build)", "Page size": "Tamaño de página", "Parameter Info": "Información de parámetros", "Parameter names": "Nombres de parámetros", diff --git a/src/platform/locales/text/fr.json b/src/platform/locales/text/fr.json index ad97c2eec..c6504aad7 100644 --- a/src/platform/locales/text/fr.json +++ b/src/platform/locales/text/fr.json @@ -1404,7 +1404,6 @@ "Package manager": "Gestionnaire de paquets", "Package to install": "Paquet à installer", "Packages": "Paquets", - "Packages the project (mvn package, gradle assemble, cargo build --release, npm run build)": "Empaquette le projet (mvn package, gradle assemble, cargo build --release, npm run build)", "Page size": "Taille de page", "Parameter Info": "Informations sur les paramètres", "Parameter names": "Noms des paramètres", diff --git a/src/platform/locales/text/ko.json b/src/platform/locales/text/ko.json index 9fb6a2fcd..e2e7434cb 100644 --- a/src/platform/locales/text/ko.json +++ b/src/platform/locales/text/ko.json @@ -1518,7 +1518,6 @@ "Package manager": "패키지 관리자", "Package to install": "설치할 패키지", "Packages": "패키지", - "Packages the project (mvn package, gradle assemble, cargo build --release, npm run build)": "프로젝트를 패키징합니다(mvn package, gradle assemble, cargo build --release, npm run build)", "Page size": "페이지 크기", "Parameter Info": "매개변수 정보", "Parameter names": "매개변수 이름", diff --git a/src/platform/locales/text/pl.json b/src/platform/locales/text/pl.json index 4bbadc52a..89a6cd766 100644 --- a/src/platform/locales/text/pl.json +++ b/src/platform/locales/text/pl.json @@ -1466,7 +1466,6 @@ "Package manager": "Menedżer pakietów", "Package to install": "Pakiet do zainstalowania", "Packages": "Pakiety", - "Packages the project (mvn package, gradle assemble, cargo build --release, npm run build)": "Pakuje projekt (mvn package, gradle assemble, cargo build --release, npm run build)", "Page size": "Rozmiar strony", "Parameter Info": "Informacje o parametrach", "Parameter names": "Nazwy parametrów", diff --git a/src/platform/locales/text/pt.json b/src/platform/locales/text/pt.json index 288127792..ee5ff7cf7 100644 --- a/src/platform/locales/text/pt.json +++ b/src/platform/locales/text/pt.json @@ -1466,7 +1466,6 @@ "Package manager": "Gerenciador de pacotes", "Package to install": "Pacote a instalar", "Packages": "Pacotes", - "Packages the project (mvn package, gradle assemble, cargo build --release, npm run build)": "Empacota o projeto (mvn package, gradle assemble, cargo build --release, npm run build)", "Page size": "Tamanho da página", "Parameter Info": "Informações de parâmetros", "Parameter names": "Nomes dos parâmetros", diff --git a/src/platform/locales/text/zh.json b/src/platform/locales/text/zh.json index bb4860e36..29fa0e2c7 100644 --- a/src/platform/locales/text/zh.json +++ b/src/platform/locales/text/zh.json @@ -1670,7 +1670,7 @@ "Package manager": "软件包管理器", "Package to install": "要安装的软件包", "Packages": "软件包", - "Packages the project (mvn package, gradle assemble, cargo build --release, npm run build)": "打包项目(mvn package、gradle assemble、cargo build --release、npm run build)", + "Packages the current module's artifacts, or the whole project when no file is active": "打包当前模块的产物,无活动文件时则打包整个项目", "Page size": "页面大小", "Parameter Info": "形参信息", "Parameter names": "形参名称",