Search in sources :

Example 6 with RockerModel

use of com.fizzed.rocker.RockerModel 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 7 with RockerModel

use of com.fizzed.rocker.RockerModel 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 8 with RockerModel

use of com.fizzed.rocker.RockerModel 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)

Example 9 with RockerModel

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

the class CreateTestCommand method call.

@Override
public Integer call() throws Exception {
    Project project = getProject(testName);
    TemplateRenderer templateRenderer = getTemplateRenderer(project);
    final String path = "/{packagePath}/{className}";
    TestRockerModelProvider provider = new DefaultTestRockerModelProvider(spock.template(project), javaJunit.template(project), groovyJunit.template(project), kotlinJunit.template(project), koTest.template(project));
    RockerModel rockerModel = provider.findModel(config.getSourceLanguage(), config.getTestFramework());
    String testPath = config.getTestFramework().getSourcePath(path, config.getSourceLanguage());
    RockerTemplate rockerTemplate = new RockerTemplate(testPath, rockerModel);
    RenderResult renderResult = templateRenderer.render(rockerTemplate);
    if (renderResult != null) {
        if (renderResult.isSuccess()) {
            out("@|blue ||@ Rendered test 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) TestRockerModelProvider(io.micronaut.starter.options.TestRockerModelProvider) DefaultTestRockerModelProvider(io.micronaut.starter.options.DefaultTestRockerModelProvider) TemplateRenderer(io.micronaut.starter.template.TemplateRenderer) DefaultTestRockerModelProvider(io.micronaut.starter.options.DefaultTestRockerModelProvider) RenderResult(io.micronaut.starter.template.RenderResult) RockerModel(com.fizzed.rocker.RockerModel)

Example 10 with RockerModel

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

the class CreateCommandCommand method call.

@Override
public Integer call() throws Exception {
    Project project = getProject(name);
    TemplateRenderer templateRenderer = getTemplateRenderer(project);
    RenderResult renderResult = null;
    if (config.getSourceLanguage() == Language.JAVA) {
        renderResult = templateRenderer.render(javaApplication.getTemplate(project), overwrite);
    } else if (config.getSourceLanguage() == Language.GROOVY) {
        renderResult = templateRenderer.render(groovyApplication.getTemplate(project), overwrite);
    } else if (config.getSourceLanguage() == Language.KOTLIN) {
        renderResult = templateRenderer.render(kotlinApplication.getTemplate(project), overwrite);
    }
    if (renderResult != null) {
        if (renderResult.isSuccess()) {
            out("Rendered command 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();
        }
    }
    Language rockerTemplateLanguage = (config.getTestFramework().getSupportedLanguages().contains(config.getSourceLanguage())) ? config.getSourceLanguage() : config.getTestFramework().getDefaultLanguage();
    TestRockerModelProvider testRockerModelProvider = new CustomTestRockerModelProvider(project, junit.getJunitRockerModelProvider(project)) {

        @Override
        public RockerModel spock() {
            return spock.getModel(getProject());
        }

        @Override
        public RockerModel koTest() {
            return koTest.getModel(project);
        }
    };
    RockerModel rockerModel = testRockerModelProvider.findModel(rockerTemplateLanguage, config.getTestFramework());
    String path = config.getTestFramework().getSourcePath(PATH, rockerTemplateLanguage);
    RockerTemplate rockerTemplate = new RockerTemplate(path, rockerModel);
    renderResult = templateRenderer.render(rockerTemplate, overwrite);
    if (renderResult != null) {
        if (renderResult.isSuccess()) {
            out("Rendered command test 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) Language(io.micronaut.starter.options.Language) TestRockerModelProvider(io.micronaut.starter.options.TestRockerModelProvider) AbstractTestRockerModelProvider(io.micronaut.starter.options.AbstractTestRockerModelProvider) 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