use of groovy.text.SimpleTemplateEngine in project gradle by gradle.
the class SimpleTemplateOperation method generate.
@Override
public void generate() {
try {
target.getParentFile().mkdirs();
SimpleTemplateEngine templateEngine = new SimpleTemplateEngine();
String templateText = Resources.asCharSource(templateURL, CharsetToolkit.getDefaultSystemCharset()).read();
Template template = templateEngine.createTemplate(templateText);
Writer writer = Files.asCharSink(target, Charsets.UTF_8).openStream();
try {
template.make(bindings).writeTo(writer);
} finally {
writer.close();
}
} catch (Exception ex) {
throw new GradleException("Could not generate file " + target + ".", ex);
}
}
Aggregations