diff --git a/vertx-codegen-processor/src/main/java/io/vertx/codegen/processor/Processor.java b/vertx-codegen-processor/src/main/java/io/vertx/codegen/processor/Processor.java index 28a90d77..3b94a1af 100644 --- a/vertx-codegen-processor/src/main/java/io/vertx/codegen/processor/Processor.java +++ b/vertx-codegen-processor/src/main/java/io/vertx/codegen/processor/Processor.java @@ -37,11 +37,10 @@ public class Processor extends AbstractProcessor { private static final String JSON_MAPPERS_PROPERTIES_PATH = "META-INF/vertx/json-mappers.properties"; - /** - * Converts the line endings of generated files to the local OS' line endings, so regenerated - * files don't show up as modified in Git diffs and IDEs. No-op when the separator is LF. - */ - private static final UnaryOperator CONVERT_TO_LOCAL_LINE_SEPARATOR = localLineSeparatorConverter(); + // Converts the line endings of generated files to the local OS' line endings + // so regenerated files don't show up as modified in Git diffs and IDEs + private static final Pattern LINE_BREAK_PATTERN = Pattern.compile("\\r\\n|\\r|\\n"); + private static final UnaryOperator CONVERT_TO_LOCAL_LINE_SEPARATOR = content -> LINE_BREAK_PATTERN.matcher(content).replaceAll(System.lineSeparator()); private File outputDirectory; private List> codeGenerators; @@ -349,13 +348,6 @@ public boolean process(Set annotations, RoundEnvironment return true; } - private static UnaryOperator localLineSeparatorConverter() { - if ("\n".equals(System.lineSeparator())) { - return UnaryOperator.identity(); - } - return content -> content.replaceAll("\n", System.lineSeparator()); - } - private void reportGenException(GenException e) { String name = e.element.toString(); if (e.element.getKind() == ElementKind.METHOD) {