use of io.micronaut.starter.template.RockerTemplate in project micronaut-starter by micronaut-projects.
the class CreateRabbitMQListener method call.
@Override
public Integer call() throws Exception {
Project project = getProject(listenerName);
TemplateRenderer templateRenderer = getTemplateRenderer(project);
RenderResult renderResult = null;
String path = "/{packagePath}/{className}";
path = config.getSourceLanguage().getSourcePath(path);
RockerModel rockerModel = null;
if (config.getSourceLanguage() == Language.JAVA) {
rockerModel = javaListener.template(project);
} else if (config.getSourceLanguage() == Language.GROOVY) {
rockerModel = groovyListener.template(project);
} else if (config.getSourceLanguage() == Language.KOTLIN) {
rockerModel = kotlinListener.template(project);
}
renderResult = templateRenderer.render(new RockerTemplate(path, rockerModel), overwrite);
if (renderResult != null) {
if (renderResult.isSuccess()) {
out("@|blue ||@ Rendered RabbitMQ listener to " + renderResult.getPath());
} else if (renderResult.isSkipped()) {
warning("Rendering skipped for " + renderResult.getPath() + " because it already exists. Run again with -f to overwrite.");
} else if (renderResult.getError() != null) {
throw renderResult.getError();
}
}
return 0;
}
use of io.micronaut.starter.template.RockerTemplate in project micronaut-starter by micronaut-projects.
the class CreateClientCommand method call.
@Override
public Integer call() throws Exception {
Project project = getProject(clientName);
TemplateRenderer templateRenderer = getTemplateRenderer(project);
RenderResult renderResult = null;
if (config.getSourceLanguage() == Language.JAVA) {
renderResult = templateRenderer.render(new RockerTemplate("src/main/java/{packagePath}/{className}Client.java", javaClient.template(project)), overwrite);
} else if (config.getSourceLanguage() == Language.GROOVY) {
renderResult = templateRenderer.render(new RockerTemplate("src/main/groovy/{packagePath}/{className}Client.groovy", groovyClient.template(project)), overwrite);
} else if (config.getSourceLanguage() == Language.KOTLIN) {
renderResult = templateRenderer.render(new RockerTemplate("src/main/kotlin/{packagePath}/{className}Client.kt", kotlinClient.template(project)), overwrite);
}
if (renderResult != null) {
if (renderResult.isSuccess()) {
out("@|blue ||@ Rendered client to " + renderResult.getPath());
} else if (renderResult.isSkipped()) {
warning("Rendering skipped for " + renderResult.getPath() + " because it already exists. Run again with -f to overwrite.");
} else if (renderResult.getError() != null) {
throw renderResult.getError();
}
}
return 0;
}
use of io.micronaut.starter.template.RockerTemplate in project micronaut-starter by micronaut-projects.
the class CreateBeanCommand method call.
@Override
public Integer call() throws Exception {
Project project = getProject(beanName);
TemplateRenderer templateRenderer = getTemplateRenderer(project);
RenderResult renderResult = null;
String path = "/{packagePath}/{className}";
path = config.getSourceLanguage().getSourcePath(path);
RockerModel rockerModel = null;
if (config.getSourceLanguage() == Language.JAVA) {
rockerModel = javaBean.template(project);
} else if (config.getSourceLanguage() == Language.GROOVY) {
rockerModel = groovyBean.template(project);
} else if (config.getSourceLanguage() == Language.KOTLIN) {
rockerModel = kotlinBean.template(project);
}
renderResult = templateRenderer.render(new RockerTemplate(path, rockerModel), overwrite);
if (renderResult != null) {
if (renderResult.isSuccess()) {
out("@|blue ||@ Rendered bean to " + renderResult.getPath());
} else if (renderResult.isSkipped()) {
warning("Rendering skipped for " + renderResult.getPath() + " because it already exists. Run again with -f to overwrite.");
} else if (renderResult.getError() != null) {
throw renderResult.getError();
}
}
return 0;
}
use of io.micronaut.starter.template.RockerTemplate in project micronaut-starter by micronaut-projects.
the class OracleRawFunction method apply.
@Override
public void apply(GeneratorContext generatorContext) {
ApplicationType type = generatorContext.getApplicationType();
if (type == ApplicationType.FUNCTION) {
applyFunction(generatorContext, type);
Language language = generatorContext.getLanguage();
Project project = generatorContext.getProject();
String sourceFile = generatorContext.getSourcePath("/{packagePath}/Function");
switch(language) {
case GROOVY:
generatorContext.addTemplate("function", new RockerTemplate(sourceFile, oracleRawFunctionGroovy.template(project)));
break;
case KOTLIN:
generatorContext.addTemplate("function", new RockerTemplate(sourceFile, oracleRawFunctionKotlin.template(project)));
break;
case JAVA:
default:
generatorContext.addTemplate("function", new RockerTemplate(sourceFile, oracleRawFunctionJava.template(project)));
}
applyTestTemplate(generatorContext, project, "Function");
}
}
use of io.micronaut.starter.template.RockerTemplate in project micronaut-starter by micronaut-projects.
the class Ktor method apply.
@Override
public void apply(GeneratorContext generatorContext) {
KotlinApplicationFeature.super.apply(generatorContext);
generatorContext.addTemplate("application", new RockerTemplate("src/main/kotlin/{packagePath}/Application.kt", applicationKotlin.template(generatorContext.getProject())));
generatorContext.addTemplate("homeRoute", new RockerTemplate("src/main/kotlin/{packagePath}/HomeRoute.kt", homeRouteKotlin.template(generatorContext.getProject())));
generatorContext.addTemplate("jacksonFeature", new RockerTemplate("src/main/kotlin/{packagePath}/JacksonFeature.kt", jacksonFeatureKotlin.template(generatorContext.getProject())));
generatorContext.addTemplate("nameTransformer", new RockerTemplate("src/main/kotlin/{packagePath}/NameTransformer.kt", nameTransformerKotlin.template(generatorContext.getProject())));
generatorContext.addTemplate("uppercaseTransformer", new RockerTemplate("src/main/kotlin/{packagePath}/UppercaseTransformer.kt", uppercaseTransformerKotlin.template(generatorContext.getProject())));
}
Aggregations