Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use space in arguments for Maven 2 exec plugin

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"
like image 264
mjn Avatar asked Jan 17 '11 18:01

mjn


2 Answers

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"
like image 126
Alexandre DuBreuil Avatar answered Sep 22 '22 06:09

Alexandre DuBreuil


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"
like image 36
Claude Avatar answered Sep 18 '22 06:09

Claude