Related Question: Maven Exec Plugin not reading configuration
In my configuration I need an argument which is a file path. I found a rather "dirty" workaround by surrounding the argument with quotes in the POM ("dirty" because the argument will be passed to the main method with these quotes, they have to be removed again in the code).
<configuration>
<executable>java</executable>
<arguments>
<argument>"path to file"</argument>
</arguments>
</configuration>
However I have found no solution for passing the path as a command line argument:
>mvn exec:java -Dexec.args="path to file"
In general, maven requires the whole argument to be quoted if there is space in the argument value.
mvn exec:java "-Dexec.args=path to file"
On the command line, you may try using single-quotes (but I'm not sure if it works), e.g.:
>mvn exec:java -Dexec.args="'path to file' arg2 arg3"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With