use of io.micronaut.starter.template.Template in project micronaut-starter by micronaut-projects.
the class DefaultProjectGenerator method generate.
@Override
public void generate(ApplicationType applicationType, Project project, OutputHandler outputHandler, GeneratorContext generatorContext) throws Exception {
List<String> features = new ArrayList<>(generatorContext.getFeatures().size());
features.addAll(generatorContext.getFeatures());
features.sort(Comparator.comparing(Function.identity()));
generatorContext.addTemplate("micronautCli", new RockerTemplate("micronaut-cli.yml", cli.template(generatorContext.getLanguage(), generatorContext.getTestFramework(), generatorContext.getBuildTool(), generatorContext.getProject(), features, applicationType)));
generatorContext.applyFeatures();
try (TemplateRenderer templateRenderer = TemplateRenderer.create(project, outputHandler)) {
for (Template template : generatorContext.getTemplates().values()) {
RenderResult renderResult = templateRenderer.render(template);
if (renderResult.getError() != null) {
throw renderResult.getError();
}
}
}
}
use of io.micronaut.starter.template.Template in project micronaut-starter by micronaut-projects.
the class Readme method apply.
@Override
public void apply(GeneratorContext generatorContext) {
List<Feature> featuresWithDocumentationLinks = generatorContext.getFeatures().getFeatures().stream().filter(feature -> feature.getMicronautDocumentation() != null || feature.getThirdPartyDocumentation() != null).collect(Collectors.toList());
List<Writable> helpTemplates = generatorContext.getHelpTemplates();
if (!helpTemplates.isEmpty() || !featuresWithDocumentationLinks.isEmpty()) {
generatorContext.addTemplate("readme", new Template() {
@Override
public String getPath() {
return "README.md";
}
@Override
public void write(OutputStream outputStream) throws IOException {
for (Writable writable : generatorContext.getHelpTemplates()) {
writable.write(outputStream);
}
for (Feature feature : featuresWithDocumentationLinks) {
Writable writable = new RockerWritable(readme.template(feature));
writable.write(outputStream);
}
}
});
}
}
Aggregations