Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

execute mvn with maven.settingsFile #776

Merged
merged 3 commits into from
Jan 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/archetype/ArchetypeModule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 5 additions & 1 deletion src/utils/mavenUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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}"`);
Expand Down Expand Up @@ -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)
Expand Down