You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by "desruisseaux (via GitHub)" <gi...@apache.org> on 2025/11/16 12:39:41 UTC

[PR] Quote filenames written in shell scripts [maven-compiler-plugin]

desruisseaux opened a new pull request, #997:
URL: https://github.com/apache/maven-compiler-plugin/pull/997

   Following https://github.com/apache/maven/pull/11435 (a change in Maven core for not quoting the files formatted by `JavaPathType` because filenames specified in `java.util.spi.ToolProvider` API shall *not* be quoted), quotes are added by the plugin instead, and only when the target is a shell script.
   
   Opportunistically add a safety when path using only for debugging purposes cannot be relativized.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Quote filenames written in shell scripts [maven-compiler-plugin]

Posted by "desruisseaux (via GitHub)" <gi...@apache.org>.
desruisseaux commented on code in PR #997:
URL: https://github.com/apache/maven-compiler-plugin/pull/997#discussion_r2541657557


##########
src/main/java/org/apache/maven/plugin/compiler/SourcePathType.java:
##########
@@ -102,7 +102,7 @@ public Optional<String> option() {
      */
     @Override
     public String[] option(Iterable<? extends Path> paths) {
-        var joiner = new StringJoiner(File.pathSeparator, (moduleName != null) ? moduleName + "=\"" : "\"", "\"");
+        var joiner = new StringJoiner(File.pathSeparator, (moduleName != null) ? moduleName + '=' : "", "");

Review Comment:
   Yes, it needs to be consistent with https://github.com/apache/maven/pull/11435.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Quote filenames written in shell scripts [maven-compiler-plugin]

Posted by "desruisseaux (via GitHub)" <gi...@apache.org>.
desruisseaux merged PR #997:
URL: https://github.com/apache/maven-compiler-plugin/pull/997


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Quote filenames written in shell scripts [maven-compiler-plugin]

Posted by "Bukama (via GitHub)" <gi...@apache.org>.
Bukama commented on code in PR #997:
URL: https://github.com/apache/maven-compiler-plugin/pull/997#discussion_r2541578493


##########
src/main/java/org/apache/maven/plugin/compiler/AbstractCompilerMojo.java:
##########
@@ -1775,7 +1781,11 @@ private void writeDebugFile(final ToolExecutor executor, final Options configura
         final var commandLine = new StringBuilder("For trying to compile from the command-line, use:");
         Path dir = basedir;
         if (dir != null) { // Should never be null, but it has been observed with some Maven versions.

Review Comment:
   I don't get this comment in together with the if statement.
   The comment says that dir should never be null, but it was observed, so I would assume the if handles the one path and an else path the rare, but observed, path if it is. But I don't see an else to handle this?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Quote filenames written in shell scripts [maven-compiler-plugin]

Posted by "desruisseaux (via GitHub)" <gi...@apache.org>.
desruisseaux commented on code in PR #997:
URL: https://github.com/apache/maven-compiler-plugin/pull/997#discussion_r2541651021


##########
src/main/java/org/apache/maven/plugin/compiler/AbstractCompilerMojo.java:
##########
@@ -1775,7 +1781,11 @@ private void writeDebugFile(final ToolExecutor executor, final Options configura
         final var commandLine = new StringBuilder("For trying to compile from the command-line, use:");
         Path dir = basedir;
         if (dir != null) { // Should never be null, but it has been observed with some Maven versions.

Review Comment:
   `basedir` is a field declared in this class as below:
   
   ```java
   @Parameter(defaultValue = "${project.basedir}", required = true, readonly = true)
   protected Path basedir;
   ```
   
   A value should always be injected by Maven core. But during the development of this plugin, sometime when upgrading from a Maven version to the next one, or when using a snapshot version compiled from `master`, the value was not supplied anymore by Maven core. For example, a similar issue can be reproduced with https://github.com/apache/maven/issues/11441 (I don't know if it was the same cause).
   
   Even if a null `basedir` may be an indication of a serious problem that we want to be aware of, in this particular context, `basedir` is used only for making a path relative when creating a debug file. This code is executed only if the build failed (or was executed with `--verbose`), so we probably don't want the original cause to be hidden by a `NullPointerException` while writing debug information.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Quote filenames written in shell scripts [maven-compiler-plugin]

Posted by "Bukama (via GitHub)" <gi...@apache.org>.
Bukama commented on code in PR #997:
URL: https://github.com/apache/maven-compiler-plugin/pull/997#discussion_r2541613412


##########
src/main/java/org/apache/maven/plugin/compiler/SourcePathType.java:
##########
@@ -102,7 +102,7 @@ public Optional<String> option() {
      */
     @Override
     public String[] option(Iterable<? extends Path> paths) {
-        var joiner = new StringJoiner(File.pathSeparator, (moduleName != null) ? moduleName + "=\"" : "\"", "\"");
+        var joiner = new StringJoiner(File.pathSeparator, (moduleName != null) ? moduleName + '=' : "", "");

Review Comment:
   Here the quotes only got removed, but not replaced. Is this correct?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Quote filenames written in shell scripts [maven-compiler-plugin]

Posted by "desruisseaux (via GitHub)" <gi...@apache.org>.
desruisseaux commented on PR #997:
URL: https://github.com/apache/maven-compiler-plugin/pull/997#issuecomment-3558663350

   Thanks all for the reviews.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org