Maven release plugin and windows line breaks

Viewed 10489

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.

4 Answers

Working in Linux, but wanting Windows line-endings in e.g. set-versions output, this quick-fix works for me:

mvn -Dline.separator=$'\r\n' \
    -DautoVersionSubmodules=true \
    -DdevelopmentVersion=1.2.3-SNAPSHOT \
    release:update-versions

I work on Windows (CRLF) and use LF endings in my files. I use Git.

I have chosen to set core.autocrlf to input. According to https://git-scm.com/book/en/v2/Customizing-Git-Git-Configuration input setting is for this situation:

If you’re on a Linux or Mac system that uses LF line endings, then you don’t want Git to automatically convert them when you check out files; however, if a file with CRLF endings accidentally gets introduced, then you may want Git to fix it. You can tell Git to convert CRLF to LF on commit but not the other way around by setting core.autocrlf to input

However, it works for me well when I am on Windows. You can give it a try if your situation is similar:

  • If CRLF file gets committed to the repository, CRLF line endings will be visible on checkout. Therefore one can react (e.g. remind colleagues to pay attention to the line endings).
  • Using Maven Release Plugin will not cause pom.xml to be committed with CRLF (it will be LF).

Downside:

  • Solution is machine-dependent. One can forget verifying Git settings before releasing from a different machine, causing CRLF pom.xml to be committed.
Related