Skip to content

Commit

Permalink
feat: Converts LF and CRLF to appropriate line ending character
Browse files Browse the repository at this point in the history
  • Loading branch information
Wykiki committed Jul 16, 2023
1 parent fd12a8d commit 74afa19
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
Expand Up @@ -396,6 +396,20 @@ public abstract class AbstractFileHeaderMojo extends AbstractLicenseNameMojo {
*/
protected abstract boolean isFailOnNotUptodateHeader();

/**
* Converts line ending string, like LF or CRLF, to proper line separator character.
*
* @param lineSeparator Line separator that may be converted.
*/
public void setLineSeparator(String lineSeparator) {
try {
this.lineSeparator = Eol.valueOf(lineSeparator).getEolString();
} catch (IllegalArgumentException e) {
LOG.warn("Unable to parse lineSeparator '{}', using it as-is.", lineSeparator);
this.lineSeparator = lineSeparator;
}
}

// ----------------------------------------------------------------------
// AbstractLicenseMojo Implementaton
// ----------------------------------------------------------------------
Expand Down
3 changes: 3 additions & 0 deletions src/site/apt/examples/update-file-header-config.apt.vm
Expand Up @@ -41,6 +41,9 @@ Update File Header Examples

* customize description section: Define a template to change the description section of a file header.

* lineSeparator: Use a custom chain of character as line separator. Providing "LF" and "CRLF" will instead use the
characters "\n" and "\r\n", respectively.

To see all extensions accepted run the <<comment-style-list>> goal.

-------------------------------------------------------------------------------
Expand Down

0 comments on commit 74afa19

Please sign in to comment.