Search in sources :

Example 6 with RockerTemplate

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

the class Maven method apply.

@Override
public void apply(GeneratorContext generatorContext) {
    ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
    generatorContext.addTemplate("mavenWrapperJar", new BinaryTemplate(WRAPPER_JAR, classLoader.getResource("maven/" + WRAPPER_JAR)));
    generatorContext.addTemplate("mavenWrapperProperties", new URLTemplate(WRAPPER_PROPS, classLoader.getResource("maven/" + WRAPPER_PROPS)));
    generatorContext.addTemplate("mavenWrapperDownloader", new URLTemplate(WRAPPER_DOWNLOADER, classLoader.getResource("maven/" + WRAPPER_DOWNLOADER)));
    generatorContext.addTemplate("mavenWrapper", new URLTemplate("mvnw", classLoader.getResource("maven/mvnw"), true));
    generatorContext.addTemplate("mavenWrapperBat", new URLTemplate("mvnw.bat", classLoader.getResource("maven/mvnw.cmd"), true));
    generatorContext.addTemplate("mavenPom", new RockerTemplate("pom.xml", pom.template(generatorContext.getApplicationType(), generatorContext.getProject(), generatorContext.getFeatures(), generatorContext.getBuildProperties().getProperties())));
    generatorContext.addTemplate("gitignore", new RockerTemplate(".gitignore", gitignore.template()));
}
Also used : RockerTemplate(io.micronaut.starter.template.RockerTemplate) BinaryTemplate(io.micronaut.starter.template.BinaryTemplate) URLTemplate(io.micronaut.starter.template.URLTemplate)

Example 7 with RockerTemplate

use of io.micronaut.starter.template.RockerTemplate 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 8 with RockerTemplate

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

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

the class UpdateCliConfigCommand method call.

@Override
public Integer call() throws Exception {
    TemplateRenderer templateRenderer = getTemplateRenderer();
    templateRenderer.render(new RockerTemplate("micronaut-cli.yml", cli.template(config.getSourceLanguage(), config.getTestFramework(), config.getBuildTool(), // Only the package is used
    NameUtils.parse(config.getDefaultPackage() + ".Ignored"), config.getFeatures(), config.getApplicationType())), true);
    out("In order to use code generation commands that are dependent on a feature, you may need to modify the feature list to include any features that are in use.");
    out("For example, in order to execute `mn create-kafka-listener`, `kafka` must be in the list of features in `micronaut-cli.yml`.");
    out(String.format("For a list of available features, run `mn %s --list-features`", COMMANDS.get(config.getApplicationType())));
    return 0;
}
Also used : RockerTemplate(io.micronaut.starter.template.RockerTemplate) TemplateRenderer(io.micronaut.starter.template.TemplateRenderer)

Example 10 with RockerTemplate

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

Aggregations

RockerTemplate (io.micronaut.starter.template.RockerTemplate)32 Project (io.micronaut.starter.application.Project)23 TemplateRenderer (io.micronaut.starter.template.TemplateRenderer)19 RenderResult (io.micronaut.starter.template.RenderResult)18 RockerModel (com.fizzed.rocker.RockerModel)14 TestRockerModelProvider (io.micronaut.starter.options.TestRockerModelProvider)6 DefaultTestRockerModelProvider (io.micronaut.starter.options.DefaultTestRockerModelProvider)5 Language (io.micronaut.starter.options.Language)5 TestFramework (io.micronaut.starter.options.TestFramework)3 ApplicationType (io.micronaut.starter.application.ApplicationType)2 BuildTool (io.micronaut.starter.options.BuildTool)2 BinaryTemplate (io.micronaut.starter.template.BinaryTemplate)2 URLTemplate (io.micronaut.starter.template.URLTemplate)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 OperatingSystem (io.micronaut.starter.application.OperatingSystem)1 CodeGenConfig (io.micronaut.starter.cli.CodeGenConfig)1 CodeGenCommand (io.micronaut.starter.cli.command.CodeGenCommand)1