Passing line.separator to maven

倾然丶 夕夏残阳落幕 提交于 2019-12-10 22:35:05

问题


I would like to pass line.separator to exec plugin but it seems that I do not correctly passing it. I have tried many combinations but could not find the solution. What is the correct way?

<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>exec-maven-plugin</artifactId>
    <version>1.2.1</version>
    <executions>
        <execution>
            <phase>test</phase>
            <goals>
                <goal>exec</goal>
            </goals>
            <configuration>
                <executable>java</executable>
               <arguments>
                   <argument>-Dline.separator=\n</argument>
                   <argument>-classpath</argument>
                   <classpath />
                   <argument>GeneratorExec</argument>
               </arguments>
            </configuration>
        </execution>
    </executions>
</plugin>

回答1:


That is not going to work. The problem is that the command is executed in a shell. The shell will interpret the \n as two characters, not one escaped.

Look at this blog: Passing '\n' (new-line) on command line in Java.

You will have to let the GeneratorExec take the two characters as an argument and then handle it in the program.



来源:https://stackoverflow.com/questions/13288030/passing-line-separator-to-maven

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!