setting JVM "line.separator" property for mvn test command
<p>We have a number of unit tests which assemble a multi-line string in memory and compare it against a reference string in a file.</p>

<p>We've gotten a bit carried away and implemented the tests to use <code>System.getProperty("line.separator")</code> to make the code OS-agnostic, but the reference files are just files with <code>\n</code> line endings (Linux), so the tests which compared generated content to reference file content fail on a Windows machine because <code>System.getProperty("line.separator")</code> returns <code>\r\n</code> there.</p>

<p>This is test code so we'll probably simply define a final String <code>LINE_ENDING="\n"</code> and update tests to use it instead of the <code>"line.separator"</code> property value, but that said, I'd really like to understand why I'm unable to specify a different line separator. I tried <code>mvn -DargLine="-Dline.separator=\n" test</code>, but the newline special character appears to have been interpreted as a literal letter <code>"n"</code> so tests failed again. To my surprise, trying <code>\\n</code> instead of <code>\n</code> made no difference, either.</p>

<p>Can anyone show how one would set the <code>line.separator</code> parameter properly?</p>

<p>Final note: the above commands were issued on a Linux machine. When running one of the tests from within Eclipse on a Windows, the <code>\n</code> special character (passed in the debug configuration as a JVM parameter <code>-Dline.separator=\n</code>) seems to be interpreted as the literal value <code>"\\n"</code>. Searching the web proves frustratingly fruitless.</p>