maven icon indicating copy to clipboard operation
maven copied to clipboard

A quoted path containing a space in MAVEN_ARGS breaks the build

Open reda-alaoui opened this issue 1 month ago • 3 comments

Affected version

3.10.0, 3.9.16

Bug description

A quoted path containing a space can't be passed through MAVEN_ARGS:

MAVEN_ARGS='"-Dmaven.repo.local=/path with space/repo"' mvn validate
[ERROR] No goals have been specified for this build. ...

Jenkins' Pipeline Maven Integration plugin passes --settings and -Dmaven.repo.local this way, so its builds fail as soon as the workspace path contains a space (jenkinsci/pipeline-maven-plugin#1525).

reda-alaoui avatar Oct 11 '26 21:10 reda-alaoui

Hi, I reproduced the description: a quoted value with a space in MAVEN_ARGS (e.g. MAVEN_ARGS='"-Dmaven.repo.local=/path with space/repo"') results in "No goals have been specified".

From an initial look, apache-maven/src/assembly/maven/bin/mvn passes MAVEN_ARGS via eval exec "$cmd" '$MAVEN_ARGS' '"$@"', and prior fixes in this area (#12348, #11983, #12465) suggest the quoting/word-splitting path. I plan to trace exactly how the quoted segment is split and check mvn.cmd for the same case.

Is this issue still available to work on, and would a fix in the launcher scripts plus a regression test be the expected direction, or would you prefer handling in the Java CLI parsing? Thanks!

Piyush00715 avatar Oct 13 '26 04:10 Piyush00715

@Piyush00715 thanks for reproducing it. There is a PR for this now: #13478. It splits MAVEN_ARGS in bin/mvn on white space, with single and double quotes grouping a word, and adds a launcher test (test-mvn-args.sh). mvn.cmd is not touched. Reviews are welcome, and so is a check of mvn.cmd on Windows if you have one at hand.

arturobernalg avatar Oct 13 '26 16:10 arturobernalg

Thanks for the update and for #13478. Since I'm on Windows, I can help with the mvn.cmd check you mentioned.

I plan to test MAVEN_ARGS="-Dmaven.repo.local=C:\path with space\repo" (double-quoted, cmd convention) vs single-quoted variant against the merged bin/mvn logic, using a minimal project with MAVEN_DEBUG_SCRIPT output to confirm whether the value arrives as one argument.

Is a Windows verification result on this issue still useful, or would you prefer it as a review comment on #13478 / a new issue if mvn.cmd still splits? Happy to follow your preference.

Piyush00715 avatar Oct 15 '26 21:10 Piyush00715