execute mvn with maven.settingsFile (#776)

This commit is contained in:
Liu Yuhui 2022-01-10 09:39:10 +08:00 коммит произвёл GitHub
Родитель 3ee38a9d96
Коммит 137610c53d
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
2 изменённых файлов: 8 добавлений и 2 удалений

Просмотреть файл

@ -76,7 +76,9 @@ export namespace ArchetypeModule {
const mvnString: string = wrappedWithQuotes(await mavenTerminal.formattedPathForTerminal(mvnPath));
const defaultArgs: string | undefined = Settings.Executable.options(metadata.targetFolder);
let commandLine: string = [mvnString, ...cmdArgs, defaultArgs].filter(Boolean).join(" ");
const mvnSettingsFile: string | undefined = Settings.getSettingsFilePath();
const mvnSettingsArg: string | undefined = mvnSettingsFile ? `-s "${await mavenTerminal.formattedPathForTerminal(mvnSettingsFile)}"` : undefined;
let commandLine: string = [mvnString, ...cmdArgs, defaultArgs, mvnSettingsArg].filter(Boolean).join(" ");
const options: vscode.ShellExecutionOptions = { cwd };
if (vscode.env.remoteName === undefined && process.platform === "win32") { // VS Code launched in Windows Desktop.
options.shellQuoting = shellQuotes.cmd;

Просмотреть файл

@ -66,7 +66,9 @@ async function executeInBackground(mvnArgs: string, pomfile?: string): Promise<a
const workspaceFolder: vscode.WorkspaceFolder | undefined = pomfile ? vscode.workspace.getWorkspaceFolder(vscode.Uri.file(pomfile)) : undefined;
const cwd: string | undefined = workspaceFolder ? path.resolve(workspaceFolder.uri.fsPath, mvn, "..") : undefined;
const userArgs: string | undefined = Settings.Executable.options(pomfile);
const matched: RegExpMatchArray | null = [mvnArgs, userArgs].filter(Boolean).join(" ").match(/(?:[^\s"]+|"[^"]*")+/g); // Split by space, but ignore spaces in quotes
const mvnSettingsFile: string | undefined = Settings.getSettingsFilePath();
const mvnSettingsArg: string | undefined = mvnSettingsFile ? `-s "${await mavenTerminal.formattedPathForTerminal(mvnSettingsFile)}"` : undefined;
const matched: RegExpMatchArray | null = [mvnSettingsArg, mvnArgs, userArgs].filter(Boolean).join(" ").match(/(?:[^\s"]+|"[^"]*")+/g); // Split by space, but ignore spaces in quotes
const args: string[] = matched !== null ? matched : [];
if (pomfile) {
args.push("-f", `"${pomfile}"`);
@ -123,8 +125,10 @@ export async function executeInTerminal(options: {
}
const mvnString: string = wrappedWithQuotes(await mavenTerminal.formattedPathForTerminal(mvn));
const mvnSettingsFile: string | undefined = Settings.getSettingsFilePath();
const fullCommand: string = [
mvnString,
mvnSettingsFile && `-s "${await mavenTerminal.formattedPathForTerminal(mvnSettingsFile)}"`,
command.trim(),
pomfile && `-f "${await mavenTerminal.formattedPathForTerminal(pomfile)}"`,
Settings.Executable.options(pomfile)