Search in sources :

Example 1 with RockerModel

use of com.fizzed.rocker.RockerModel in project micronaut-starter by micronaut-projects.

the class CreateKafkaProducer method call.

@Override
public Integer call() throws Exception {
    Project project = getProject(producerName);
    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 = javaProducer.template(project);
    } else if (config.getSourceLanguage() == Language.GROOVY) {
        rockerModel = groovyProducer.template(project);
    } else if (config.getSourceLanguage() == Language.KOTLIN) {
        rockerModel = kotlinProducer.template(project);
    }
    renderResult = templateRenderer.render(new RockerTemplate(path, rockerModel), overwrite);
    if (renderResult != null) {
        if (renderResult.isSuccess()) {
            out("@|blue ||@ Rendered Kafka producer 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;
}
Also used : RockerTemplate(io.micronaut.starter.template.RockerTemplate) Project(io.micronaut.starter.application.Project) TemplateRenderer(io.micronaut.starter.template.TemplateRenderer) RenderResult(io.micronaut.starter.template.RenderResult) RockerModel(com.fizzed.rocker.RockerModel)

Example 2 with RockerModel

use of com.fizzed.rocker.RockerModel in project micronaut-starter by micronaut-projects.

the class CreateNatsProducer method call.

@Override
public Integer call() throws Exception {
    Project project = getProject(producerName);
    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 = javaProducer.template(project);
    } else if (config.getSourceLanguage() == Language.GROOVY) {
        rockerModel = groovyProducer.template(project);
    } else if (config.getSourceLanguage() == Language.KOTLIN) {
        rockerModel = kotlinProducer.template(project);
    }
    renderResult = templateRenderer.render(new RockerTemplate(path, rockerModel), overwrite);
    if (renderResult != null) {
        if (renderResult.isSuccess()) {
            out("@|blue ||@ Rendered Nats producer 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;
}
Also used : RockerTemplate(io.micronaut.starter.template.RockerTemplate) Project(io.micronaut.starter.application.Project) TemplateRenderer(io.micronaut.starter.template.TemplateRenderer) RenderResult(io.micronaut.starter.template.RenderResult) RockerModel(com.fizzed.rocker.RockerModel)

Example 3 with RockerModel

use of com.fizzed.rocker.RockerModel in project micronaut-starter by micronaut-projects.

the class CreateRabbitMQProducer method call.

@Override
public Integer call() throws Exception {
    Project project = getProject(producerName);
    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 = javaProducer.template(project);
    } else if (config.getSourceLanguage() == Language.GROOVY) {
        rockerModel = groovyProducer.template(project);
    } else if (config.getSourceLanguage() == Language.KOTLIN) {
        rockerModel = kotlinProducer.template(project);
    }
    renderResult = templateRenderer.render(new RockerTemplate(path, rockerModel), overwrite);
    if (renderResult != null) {
        if (renderResult.isSuccess()) {
            out("@|blue ||@ Rendered RabbitMQ producer 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;
}
Also used : RockerTemplate(io.micronaut.starter.template.RockerTemplate) Project(io.micronaut.starter.application.Project) TemplateRenderer(io.micronaut.starter.template.TemplateRenderer) RenderResult(io.micronaut.starter.template.RenderResult) RockerModel(com.fizzed.rocker.RockerModel)

Example 4 with RockerModel

use of com.fizzed.rocker.RockerModel in project micronaut-starter by micronaut-projects.

the class AwsLambdaCustomRuntime method addBootstrap.

private void addBootstrap(GeneratorContext generatorContext, ApplicationType applicationType) {
    RockerModel bootstrapRockerModel = bootstrap.template(applicationType, generatorContext.getProject(), generatorContext.getBuildTool(), generatorContext.getFeatures());
    generatorContext.addTemplate("bootstrap", new RockerTemplate("bootstrap", bootstrapRockerModel));
}
Also used : RockerTemplate(io.micronaut.starter.template.RockerTemplate) RockerModel(com.fizzed.rocker.RockerModel)

Example 5 with RockerModel

use of com.fizzed.rocker.RockerModel in project micronaut-starter by micronaut-projects.

the class CreateJobCommand method call.

@Override
public Integer call() throws Exception {
    Project project = getProject(jobName);
    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 = javaJob.template(project);
    } else if (config.getSourceLanguage() == Language.GROOVY) {
        rockerModel = groovyJob.template(project);
    } else if (config.getSourceLanguage() == Language.KOTLIN) {
        rockerModel = kotlinJob.template(project);
    }
    renderResult = templateRenderer.render(new RockerTemplate(path, rockerModel), overwrite);
    if (renderResult != null) {
        if (renderResult.isSuccess()) {
            out("@|blue ||@ Rendered job 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;
}
Also used : RockerTemplate(io.micronaut.starter.template.RockerTemplate) Project(io.micronaut.starter.application.Project) TemplateRenderer(io.micronaut.starter.template.TemplateRenderer) RenderResult(io.micronaut.starter.template.RenderResult) RockerModel(com.fizzed.rocker.RockerModel)

Aggregations

RockerModel (com.fizzed.rocker.RockerModel)14 RockerTemplate (io.micronaut.starter.template.RockerTemplate)14 Project (io.micronaut.starter.application.Project)12 RenderResult (io.micronaut.starter.template.RenderResult)12 TemplateRenderer (io.micronaut.starter.template.TemplateRenderer)12 TestRockerModelProvider (io.micronaut.starter.options.TestRockerModelProvider)3 DefaultTestRockerModelProvider (io.micronaut.starter.options.DefaultTestRockerModelProvider)2 AbstractTestRockerModelProvider (io.micronaut.starter.options.AbstractTestRockerModelProvider)1 Language (io.micronaut.starter.options.Language)1