Search in sources :

Example 6 with RenderResult

use of io.micronaut.starter.template.RenderResult 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)

Example 7 with RenderResult

use of io.micronaut.starter.template.RenderResult in project micronaut-starter by micronaut-projects.

the class CreateNatsListener method call.

@Override
public Integer call() throws Exception {
    Project project = getProject(listenerName);
    TemplateRenderer templateRenderer = getTemplateRenderer(project);
    String path = "/{packagePath}/{className}";
    path = config.getSourceLanguage().getSourcePath(path);
    RenderResult renderResult = null;
    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 Nats 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;
}
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 8 with RenderResult

use of io.micronaut.starter.template.RenderResult 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;
}
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 9 with RenderResult

use of io.micronaut.starter.template.RenderResult 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;
}
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)

Example 10 with RenderResult

use of io.micronaut.starter.template.RenderResult 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;
}
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

RenderResult (io.micronaut.starter.template.RenderResult)18 RockerTemplate (io.micronaut.starter.template.RockerTemplate)18 TemplateRenderer (io.micronaut.starter.template.TemplateRenderer)18 Project (io.micronaut.starter.application.Project)17 RockerModel (com.fizzed.rocker.RockerModel)12 TestRockerModelProvider (io.micronaut.starter.options.TestRockerModelProvider)3 DefaultTestRockerModelProvider (io.micronaut.starter.options.DefaultTestRockerModelProvider)2 Language (io.micronaut.starter.options.Language)2 Parameter (io.micronaut.context.annotation.Parameter)1 Prototype (io.micronaut.context.annotation.Prototype)1 ReflectiveAccess (io.micronaut.core.annotation.ReflectiveAccess)1 ThrowingSupplier (io.micronaut.core.util.functional.ThrowingSupplier)1 CodeGenConfig (io.micronaut.starter.cli.CodeGenConfig)1 CodeGenCommand (io.micronaut.starter.cli.command.CodeGenCommand)1 DatabaseDriverFeature (io.micronaut.starter.feature.database.DatabaseDriverFeature)1 ConsoleOutput (io.micronaut.starter.io.ConsoleOutput)1 OutputHandler (io.micronaut.starter.io.OutputHandler)1 AbstractTestRockerModelProvider (io.micronaut.starter.options.AbstractTestRockerModelProvider)1 Template (io.micronaut.starter.template.Template)1 IOException (java.io.IOException)1