开发者

How to use space in arguments for Maven 2 exec plugin

开发者 https://www.devze.com 2023-02-05 17:00 出处:网络
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 quote

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"


Use -Dexec.args="'space parameter' normalparameter 'one more space parameter'"

I've tried it on Windows and it works.


If you want it in command line try: $ mvn exec:java -Dexec.args="path\ to\ file arg2 arg3"


Try -Dexec.arguments="path to file" (instead of -Dexec.args="path to file")

Check here for details.

0

精彩评论

暂无评论...
验证码 换一张
取 消