Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Maven release plugin and windows line breaks

Tags:

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.

like image 484
realsim Avatar asked Aug 08 '12 16:08

realsim


People also ask

How does maven release plugin work?

The plugin will extract file revisions associated with the current release. Maven will compile, test and package the versioned project source code into an artifact. The final deliverable will then be released into an appropriate maven repository.

What is version release in Maven?

When you depend on a plugin or a dependency, you can use the a version value of LATEST or RELEASE. LATEST refers to the latest released or snapshot version of a particular artifact, the most recently deployed artifact in a particular repository. RELEASE refers to the last non-snapshot release in the repository.


1 Answers

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.

like image 60
Virmundi Avatar answered Oct 18 '22 19:10

Virmundi