Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make Maven checking the source end-of-line?

I would like to enforce Unix style end-of-line (\n) in Java sources of our projects for consistency reasons. As many of us work under Windows, most IDEs are configured by default to use Windows style end-of-line (\r\n). We try to change that settings each time we configure a new workspace but for some reasons, some files are commited with Windows end-of-line.

Is there any Maven configuration or plugin which could help us enforcing the Unix style end-of-line or, at least, warning us of the files that are in Windows style?

I though about PMD or Checkstyle first but it doesn't appear to be that simple. I've also checked Maven Enforcer Plugin but I don't think it do that out-of-the box. I should be able to create my own rule but I'd like to make sure I don't reinvent the wheel :)

like image 810
Florent Paillard Avatar asked Dec 27 '22 08:12

Florent Paillard


1 Answers

Use Checkstyle, we used it successfully in our project to enforce Unix line endings.

You can use a regular expression to do this ( a windows line ending is \r\n, but you probably know that).

like image 51
kutschkem Avatar answered Dec 28 '22 23:12

kutschkem