Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(generator): standardize line endings in generated element templates #2288

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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