Search code examples
maven-release-pluginline-endings

Maven release plugin and windows line breaks


when i try to run the maven-release-plugin it changes the version in the pom.xml file. Prior to the maven release every line ending has unix style <lf> but after running it on my windows machine, the plugin changes every line in the file to <cr><lf>.

My questions are:

a) Is there a way to tell maven to leave everything as it is or to use a specific line ending

or

b) Is there a general way to tell windows what the line ending should be? Even a tool that hacks something deep down in the OS would be considered helpful.

I had a look at this https://issues.jfrog.org/jira/browse/BI-111 and it says "resolved" but i am using the latest version and it doesn't work for me.


Solution

  • There are four possible solutions.

    1. Use the Maven Assemly Plugin

    I think the best idea is investigate the Maven assembly plugin. It should allow you to update the line separator. See the section "fileSet" section for details.

    1. Use PowerShell to call mvn

    As a temporary work around, you can use PowerShell (Start->All Programs->Accessories->Windows PowerShell). Call maven like you would, with some extras around double quoting the -D statements. mvn assembly:assembly -P prod "-Dmaven.test.skip=true". Now add to this -Dline.separator=`n. This should cause PowerShell to add the escaped value.

    1. Write your own plugin to override "line.separator" before the pom is updated.

    Follow the Maven Guide on creating a simple plugin. All it needs to do is override value. Configure the plugin to execute in the phase prior to the pom modification.

    System.getProperties().setProperty("line.separator", "\n");
    
    1. Build in a Linux VM.

    There is an option that doesn't correct the Windows compatibility issue, but should solve your core problem. Look at creating small VirtualBox Linux server. A simple NAT connection should suffice for Internet access. Install Maven, Java, etc on this machine. Build on it. Because it's Linux the line separator should be only '\n'. The VM would need 256 - 512 MB of RAM and 20 GB of storage space (Linux + a lot of possible Maven dependencies). If you end up liking it, you could even expand it to house a continuous integration product like Jenkins.