fix(settings): flag a Maven thread count Maven would not accept

Settings › Maven › Thread count silently dropped values other than a count
(4) or a core multiplier (2C, 2.5C), so builds ran serially with no hint.
The field now marks such a value as invalid and says why.
Цей коміт міститься в:
l0ng-ai committed 2026-11-20 18:57:58 +08:00
1 джерело 85347088e6
коміт f0b25501f5
5 files changed
+35 -3

No files matched your search

+15 -1
Переглянути файл
@@ -14,6 +14,7 @@ import { GlobListEditor, Row, Section, Select, Toggle } from "../components/Form
import { choosePath } from "@/platform/choosePath";
import { usePageContext, useSetting } from "../components/context";
import { SdkField, tildify, useDetected, useJdtlsJdk } from "./components";
import { isMavenThreadCount } from "./mavenThreads";
import styles from "./Sdk.module.css";
function PathInput({
@@ -566,6 +567,7 @@ export function MavenPage() {
const [downloadSources, setDownloadSources] = useSetting<boolean>("languages.java.maven.downloadSources");
const [updateSnapshots, setUpdateSnapshots] = useSetting<boolean>("languages.java.maven.updateSnapshots");
const [threads, setThreads] = useSetting<string>("languages.java.maven.threads");
const threadsInvalid = !!threads?.trim() && !isMavenThreadCount(threads);
const [activeProfiles, setActiveProfiles] = useSetting<string>("languages.java.maven.activeProfiles");
const id = useId();
return (
@@ -651,12 +653,24 @@ export function MavenPage() {
<Row
label="Thread count"
htmlFor={id}
hint="Passed as -T to Maven builds and run configurations: a thread count (4) or a core multiplier (2C, 2.5C) for parallel builds of multi-module projects. Empty runs Maven serially."
hint={
threadsInvalid ? (
<span className={styles.error} role="alert">
<T>
Not a thread count Maven accepts, so builds run serially. Use a number (4) or a core multiplier (2C,
2.5C).
</T>
</span>
) : (
"Passed as -T to Maven builds and run configurations: a thread count (4) or a core multiplier (2C, 2.5C) for parallel builds of multi-module projects. Empty runs Maven serially."
)
}
>
<span className={styles.pathRow}>
<Input
id={id}
mono
invalid={threadsInvalid}
className={styles.pathInput}
value={threads}
placeholder="4, 2C"
+8
Переглянути файл
@@ -0,0 +1,8 @@
import { expect, it } from "vitest";
import { isMavenThreadCount } from "./mavenThreads";
it("accepts the -T values Maven takes and nothing else (#4743)", () => {
for (const ok of ["4", "1C", "2.5C", "0.5C", " 8 "]) expect(isMavenThreadCount(ok), ok).toBe(true);
for (const bad of ["0", "0C", "-2", "2c", "2.C", ".5C", "2.5.1C", "four", "4 threads", "C"])
expect(isMavenThreadCount(bad), bad).toBe(false);
});
+8
Переглянути файл
@@ -0,0 +1,8 @@
/**
* Whether Maven accepts `value` as `-T`: a thread count (`4`) or a core multiplier with an
* optional decimal fraction (`1C`, `2.5C`). Mirrors `MavenSettings::thread_count`, which
* leaves any other value out of the command line.
*/
export function isMavenThreadCount(value: string): boolean {
return /^(?:\d+(?:\.\d+)?)C?$/.test(value.trim()) && parseFloat(value) > 0;
}
+2 -1
Переглянути файл
@@ -2789,5 +2789,6 @@
"Download to {folder} finished with errors": "Download to {folder} finished with errors",
"Cannot download to {folder}": "Cannot download to {folder}",
"Copy the selected files and folders of a remote project to a folder on this computer": "Copy the selected files and folders of a remote project to a folder on this computer",
"{modifier}+Click to only see \"{name}\"": "{modifier}+Click to only see \"{name}\""
"{modifier}+Click to only see \"{name}\"": "{modifier}+Click to only see \"{name}\"",
"Not a thread count Maven accepts, so builds run serially. Use a number (4) or a core multiplier (2C, 2.5C).": "Not a thread count Maven accepts, so builds run serially. Use a number (4) or a core multiplier (2C, 2.5C)."
}
+2 -1
Переглянути файл
@@ -9152,5 +9152,6 @@
"Download to {folder} finished with errors": "下载到 {folder} 完成,但有错误",
"Cannot download to {folder}": "无法下载到 {folder}",
"Copy the selected files and folders of a remote project to a folder on this computer": "把远程项目中选中的文件和文件夹复制到本机的文件夹",
"{modifier}+Click to only see \"{name}\"": "{modifier}+点击仅显示“{name}”"
"{modifier}+Click to only see \"{name}\"": "{modifier}+点击仅显示“{name}”",
"Not a thread count Maven accepts, so builds run serially. Use a number (4) or a core multiplier (2C, 2.5C).": "Maven 不接受这个线程数,构建将串行执行。请填写数字(4)或核数倍数(2C、2.5C)。"
}