From 6c1876fc5488c260c5a35e2b060d83cec64ef1fe Mon Sep 17 00:00:00 2001 From: Martin Desruisseaux Date: Thu, 13 Nov 2025 10:50:55 +0100 Subject: [PATCH] =?UTF-8?q?Revert=20the=20quoting=20of=20filenames=20in=20?= =?UTF-8?q?`JavaPathType.option(=E2=80=A6)`.=20This=20is=20a=20partial=20r?= =?UTF-8?q?evert=20of=20https://github.com/apache/maven/pull/2505=20based?= =?UTF-8?q?=20on=20the=20observation=20that=20above=20PR=20has=20not=20bee?= =?UTF-8?q?n=20merged=20in=204.0.x.=20For=20making=20the=20two=20branches?= =?UTF-8?q?=20consistent,=20we=20need=20to=20either=20port=20or=20revert?= =?UTF-8?q?=202505.=20A=20revert=20is=20less=20disruptive=20as=20no=20Mave?= =?UTF-8?q?n=204.1.x=20version=20has=20been=20released=20yet=20and=20it=20?= =?UTF-8?q?would=20avoid=20https://github.com/apache/maven-compiler-plugin?= =?UTF-8?q?/pull/991.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/org/apache/maven/api/JavaPathType.java | 6 ++++-- .../test/java/org/apache/maven/api/JavaPathTypeTest.java | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/api/maven-api-core/src/main/java/org/apache/maven/api/JavaPathType.java b/api/maven-api-core/src/main/java/org/apache/maven/api/JavaPathType.java index b2e98ed3c6ad..4762a4093269 100644 --- a/api/maven-api-core/src/main/java/org/apache/maven/api/JavaPathType.java +++ b/api/maven-api-core/src/main/java/org/apache/maven/api/JavaPathType.java @@ -244,6 +244,7 @@ public Optional option() { * Returns the option followed by a string representation of the given path elements. * For example, if this type is {@link #MODULES}, then the option is {@code "--module-path"} * followed by the specified path elements. + * The paths are not quoted. * * @param paths the path to format as a tool option * @return the option associated to this path type followed by the given path elements, @@ -263,8 +264,8 @@ final String[] format(String moduleName, Iterable paths) { if (option == null) { throw new IllegalStateException("No option is associated to this path type."); } - String prefix = (moduleName == null) ? "\"" : (moduleName + "=\""); - StringJoiner joiner = new StringJoiner(File.pathSeparator, prefix, "\""); + String prefix = (moduleName == null) ? "" : (moduleName + '='); + StringJoiner joiner = new StringJoiner(File.pathSeparator, prefix, ""); joiner.setEmptyValue(""); for (Path p : paths) { joiner.add(p.toString()); @@ -365,6 +366,7 @@ public Optional option() { * Returns the option followed by a string representation of the given path elements. * The path elements are separated by an option-specific or platform-specific separator. * If the given {@code paths} argument contains no element, then this method returns an empty string. + * The paths are not quoted. * * @param paths the path to format as a string * @return the option associated to this path type followed by the given path elements, diff --git a/api/maven-api-core/src/test/java/org/apache/maven/api/JavaPathTypeTest.java b/api/maven-api-core/src/test/java/org/apache/maven/api/JavaPathTypeTest.java index 701a82775bde..d05f86070682 100644 --- a/api/maven-api-core/src/test/java/org/apache/maven/api/JavaPathTypeTest.java +++ b/api/maven-api-core/src/test/java/org/apache/maven/api/JavaPathTypeTest.java @@ -53,7 +53,7 @@ public void testOption() { String[] formatted = JavaPathType.MODULES.option(paths()); assertEquals(2, formatted.length); assertEquals("--module-path", formatted[0]); - assertEquals(toPlatformSpecific("\"src/foo.java:src/bar.java\""), formatted[1]); + assertEquals(toPlatformSpecific("src/foo.java:src/bar.java"), formatted[1]); } /** @@ -64,7 +64,7 @@ public void testModularOption() { String[] formatted = JavaPathType.patchModule("my.module").option(paths()); assertEquals(2, formatted.length); assertEquals("--patch-module", formatted[0]); - assertEquals(toPlatformSpecific("my.module=\"src/foo.java:src/bar.java\""), formatted[1]); + assertEquals(toPlatformSpecific("my.module=src/foo.java:src/bar.java"), formatted[1]); } /**