reda-alaoui opened a new pull request, #13412:
URL: https://github.com/apache/maven/pull/13412
`CleanArgument.cleanArgs` is meant to rejoin a double-quoted argument that
the shell split on whitespace. It never closes such an argument: the closing
quote is only honoured on the token that opened the quote.
```java
if (addedToBuffer && arg.endsWith("\"")) {
```
So the token carrying the closing quote is appended to the buffer like any
other, and so is every following argument, goals included.
Reproducer (Maven 3.9.16 and 3.10.0), in any project:
```
mvn '"-Dfoo=a' 'b"' validate
```
```
[ERROR] No goals have been specified for this build. ...
```
Expected: `foo` = `a b`, and `validate` runs. A quoted argument that is a
single token (`mvn '"-Dfoo=a b"' validate`) works.
This happens in practice through `MAVEN_ARGS`, which `bin/mvn` expands
unquoted: `MAVEN_ARGS='"-Dmaven.repo.local=/path with space/repo"' mvn
validate` fails the same way. Jenkins' Pipeline Maven Integration plugin builds
`--settings "<path>"` and `"-Dmaven.repo.local=<path>"` arguments this way, and
fails as soon as the workspace path contains a space
(jenkinsci/pipeline-maven-plugin#1525).
The fix closes the argument on a trailing quote whenever one is being built,
and restores the branch that appends the closing token without its quote (still
present on maven-3.9.x, dropped on master as unreachable). It is applied to
both copies:
-
`compat/maven-embedder/src/main/java/org/apache/maven/cli/CleanArgument.java`
-
`impl/maven-cli/src/main/java/org/apache/maven/cling/invoker/CleanArgument.java`
maven-3.9.x and maven-3.10.x have the same bug in
`maven-embedder/src/main/java/org/apache/maven/cli/CleanArgument.java`: please
consider a backport.
---
To make clear that you license your contribution under
the [Apache License Version 2.0, January
2004](https://www.apache.org/licenses/LICENSE-2.0)
check one of the following:
- [x] I hereby declare this contribution to be licensed under the [Apache
License Version 2.0, January 2004](https://www.apache.org/licenses/LICENSE-2.0)
- [ ] I hereby declare that I have filed an [Apache Individual Contributor
License Agreement](https://www.apache.org/licenses/icla.pdf).
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]