2

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>
4

1 回答 1

3

那是行不通的。问题是该命令是在 shell 中执行的。shell 会将其解释\n为两个字符,而不是一个转义字符。

看看这个博客:Passing '\n' (new-line) on command line in Java

您将不得不让GeneratorExec这两个字符作为参数,然后在程序中处理它。

于 2012-11-08T11:43:58.800 回答