Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import java.io.File;
import java.io.IOException;
import java.io.StringWriter;
import java.io.UncheckedIOException;
import java.io.Writer;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
Expand Down Expand Up @@ -154,9 +155,10 @@ protected void doExecute() throws MojoExecutionException {
}

/**
* Do render the template.
* @param artifacts input.
* @return the template rendered.
* Render the template.
*
* @param artifacts input
* @return the template rendered
*/
private String render(final List<Artifact> artifacts) {
final Path templatePath = getTemplatePath();
Expand All @@ -178,20 +180,18 @@ private String render(final List<Artifact> artifacts) {
context.put("sorter", new CollectionTool());

// Merge template + context
final StringWriter writer = new StringWriter();
try (StringWriter ignored = writer) {
try (StringWriter writer = new StringWriter()) {
if (fromFile) {
final Template template =
ve.getTemplate(templatePath.getFileName().toString());
template.merge(context, writer);
} else {
ve.evaluate(context, writer, "tpl-" + Math.abs(hashCode()), template);
}
return writer.toString();
} catch (final IOException e) {
// no-op, not possible
throw new UncheckedIOException("not possible", e);
}

return writer.toString();
}

private Path getTemplatePath() {
Expand Down