Skip to content

Commit

Permalink
fix(generator): standardize line endings in generated element templat…
Browse files Browse the repository at this point in the history
…es (#2288)
  • Loading branch information
markfarkas-camunda committed Apr 2, 2024
1 parent e7566e0 commit 248dd05
Showing 1 changed file with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@
*/
package io.camunda.connector.generator;

import com.fasterxml.jackson.core.util.DefaultIndenter;
import com.fasterxml.jackson.core.util.DefaultPrettyPrinter;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.ObjectWriter;
import io.camunda.connector.generator.ConnectorConfig.FileNameById;
import io.camunda.connector.generator.api.GeneratorConfiguration;
import io.camunda.connector.generator.api.GeneratorConfiguration.ConnectorMode;
Expand Down Expand Up @@ -56,7 +59,11 @@ public class ElementTemplateGeneratorMojo extends AbstractMojo {
@Parameter(property = "outputDirectory", defaultValue = "${project.basedir}/element-templates")
private String outputDirectory;

private static final ObjectMapper mapper = new ObjectMapper();
private static final ObjectWriter objectWriter =
new ObjectMapper()
.writer(
new DefaultPrettyPrinter()
.withObjectIndenter(new DefaultIndenter().withLinefeed("\n")));

private static final String COMPILED_CLASSES_DIR = "target" + File.separator + "classes";
private static final String HYBRID_TEMPLATES_DIR = "hybrid";
Expand Down Expand Up @@ -193,7 +200,7 @@ private void writeElementTemplate(ElementTemplate template, boolean hybrid, Stri
file = new File(outputDirectory + File.separator + HYBRID_TEMPLATES_DIR, fileName);
file.getParentFile().mkdirs();
}
mapper.writerWithDefaultPrettyPrinter().writeValue(file, template);
objectWriter.writeValue(file, template);
} catch (Exception e) {
throw new RuntimeException("Failed to write element template", e);
}
Expand Down

0 comments on commit 248dd05

Please sign in to comment.