From 43618e6dffb6f8a28defa27ea424bd3e07321b7a Mon Sep 17 00:00:00 2001 From: Israel Merljak <17605203+imerljak@users.noreply.github.com> Date: Tue, 12 Nov 2024 06:58:57 +0000 Subject: [PATCH] feature: maven.executable.options configuration as list of strings (#1032) * feature: maven.executable.options configuration as list of strings Closes #981 * fix json format in README fix json format in README --------- Co-authored-by: Jinbo Wang --- README.md | 2 +- package.json | 14 ++++++++++++-- src/Settings.ts | 6 +++++- 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 19ffc953..2f65924c 100644 --- a/README.md +++ b/README.md @@ -137,7 +137,7 @@ The usage of Maven executable is: You can use `maven.executable.options` to specify default **options** for all your Maven commands executed in current project. ```json { - "maven.executable.options": "-o -s ./settings.xml" // work offline, and use an alternative settings file + "maven.executable.options": "-o -s ./settings.xml" // work offline and use an alternative settings file. Can also be defined as an array of strings, e.g. ["-o", "-s ./settings.xml"] } ``` diff --git a/package.json b/package.json index 6e281c84..a22c0a56 100644 --- a/package.json +++ b/package.json @@ -662,7 +662,17 @@ "scope": "machine" }, "maven.executable.options": { - "type": "string", + "anyOf": [ + { + "type": "string" + }, + { + "type": "array", + "items": { + "type": "string" + } + } + ], "default": "", "description": "%configuration.maven.executable.options%", "scope": "machine-overridable" @@ -852,4 +862,4 @@ "which": "^1.3.1", "xml2js": "^0.5.0" } -} \ No newline at end of file +} diff --git a/src/Settings.ts b/src/Settings.ts index 17aebe72..11d06830 100644 --- a/src/Settings.ts +++ b/src/Settings.ts @@ -79,7 +79,11 @@ export class Settings { return _getMavenSection("executable.path", resourceOrFilepath); } public static options(resourceOrFilepath?: Uri | string): string | undefined { - return _getMavenSection("executable.options", resourceOrFilepath); + const options: string | string[] | undefined = _getMavenSection("executable.options", resourceOrFilepath); + if (Array.isArray(options)) { + return options.join(' '); + } + return options; } public static preferMavenWrapper(resourceOrFilepath?: Uri | string): boolean { return !!_getMavenSection("executable.preferMavenWrapper", resourceOrFilepath);