When the shell expands -Dexec.args="$@"
and the list of positional parameters is arg1
, arg2
, arg3
, then you get the list -Dexec.args=arg1
, arg2
, arg3
(three separate arguments for mvn
). The "$@"
expansion is always a list, and the result of concatenating that with a string, as you do in your code, is not actually well defined (most shells behave as I describe here).
What you likely want is "$*"
in place of "$@"
. The expansion of "$*"
is always a single string made up of the elements of the list of positional parameters, concatenated bywith the first character from $IFS
(usually a space) as the delimiter.
With
With -Dexec.args="$*"
you get the string -Dexec.args=arg1 arg2 arg3
(one single argument for mvn
).
So:
mvn exec:java -Dexec.mainClass=my.App -Dexec.args="$*"
Note that if any argument contains spaces, it will be difficult for mvn
to parse it correctly unless the tool supports some special escaping, quoting, or other encoding for handling that (and you use that in the argument list). I'm not a Maven user, so I don't know how it parses the exec.args
value.