Search in sources :

Example 26 with RockerTemplate

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

the class Gradle method apply.

@Override
public void apply(GeneratorContext generatorContext) {
    ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
    generatorContext.addTemplate("gradleWrapperJar", new BinaryTemplate(WRAPPER_JAR, classLoader.getResource(WRAPPER_JAR)));
    generatorContext.addTemplate("gradleWrapperProperties", new URLTemplate(WRAPPER_PROPS, classLoader.getResource(WRAPPER_PROPS)));
    generatorContext.addTemplate("gradleWrapper", new URLTemplate("gradlew", classLoader.getResource("gradle/gradlew"), true));
    generatorContext.addTemplate("gradleWrapperBat", new URLTemplate("gradlew.bat", classLoader.getResource("gradle/gradlew.bat"), true));
    BuildTool buildTool = generatorContext.getBuildTool();
    generatorContext.addTemplate("build", new RockerTemplate(buildTool.getBuildFileName(), buildGradle.template(generatorContext.getApplicationType(), generatorContext.getProject(), generatorContext.getFeatures(), buildTool == BuildTool.GRADLE_KOTLIN)));
    generatorContext.addTemplate("gitignore", new RockerTemplate(".gitignore", gitignore.template()));
    generatorContext.addTemplate("projectProperties", new RockerTemplate("gradle.properties", gradleProperties.template(generatorContext.getBuildProperties().getProperties())));
    String settingsFile = buildTool == BuildTool.GRADLE ? "settings.gradle" : "settings.gradle.kts";
    generatorContext.addTemplate("gradleSettings", new RockerTemplate(settingsFile, settingsGradle.template(generatorContext.getProject())));
}
Also used : RockerTemplate(io.micronaut.starter.template.RockerTemplate) BinaryTemplate(io.micronaut.starter.template.BinaryTemplate) URLTemplate(io.micronaut.starter.template.URLTemplate) BuildTool(io.micronaut.starter.options.BuildTool)

Example 27 with RockerTemplate

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

the class GeneratorContext method addTemplate.

public void addTemplate(String templateName, String triggerFile, RockerModel javaTemplate, RockerModel kotlinTemplate, RockerModel groovyTemplate) {
    RockerModel rockerModel = parseModel(javaTemplate, kotlinTemplate, groovyTemplate);
    addTemplate(templateName, new RockerTemplate(triggerFile, rockerModel));
}
Also used : RockerTemplate(io.micronaut.starter.template.RockerTemplate) RockerModel(com.fizzed.rocker.RockerModel)

Example 28 with RockerTemplate

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

the class AbstractFunctionFeature method applyFunction.

protected void applyFunction(GeneratorContext generatorContext, ApplicationType type) {
    BuildTool buildTool = generatorContext.getBuildTool();
    generatorContext.addHelpTemplate(new RockerWritable(readmeTemplate(generatorContext, generatorContext.getProject(), buildTool)));
    if (type == ApplicationType.DEFAULT) {
        final String className = StringUtils.capitalize(generatorContext.getProject().getPropertyName());
        Project project = generatorContext.getProject().withClassName(className);
        Language language = generatorContext.getLanguage();
        String sourceFile = generatorContext.getSourcePath("/{packagePath}/" + className + "Controller");
        switch(language) {
            case GROOVY:
                generatorContext.addTemplate("function", new RockerTemplate(sourceFile, groovyControllerTemplate(project)));
                break;
            case KOTLIN:
                generatorContext.addTemplate("function", new RockerTemplate(sourceFile, kotlinControllerTemplate(project)));
                break;
            case JAVA:
            default:
                generatorContext.addTemplate("function", new RockerTemplate(sourceFile, javaControllerTemplate(project)));
                break;
        }
        applyTestTemplate(generatorContext, project, className + getTestSuffix(type));
    }
}
Also used : RockerTemplate(io.micronaut.starter.template.RockerTemplate) Project(io.micronaut.starter.application.Project) RockerWritable(io.micronaut.starter.template.RockerWritable) Language(io.micronaut.starter.options.Language) BuildTool(io.micronaut.starter.options.BuildTool)

Example 29 with RockerTemplate

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

the class OracleFunction method apply.

@Override
public void apply(GeneratorContext generatorContext) {
    generatorContext.addTemplate("func.yml", new RockerTemplate("func.yml", projectFnFunc.template(generatorContext.getProject())));
    applyFunction(generatorContext, generatorContext.getApplicationType());
}
Also used : RockerTemplate(io.micronaut.starter.template.RockerTemplate)

Example 30 with RockerTemplate

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

the class KotlinApplication method apply.

@Override
public void apply(GeneratorContext generatorContext) {
    KotlinApplicationFeature.super.apply(generatorContext);
    if (shouldGenerateApplicationFile(generatorContext)) {
        generatorContext.addTemplate("application", new RockerTemplate(getPath(), application.template(generatorContext.getProject(), generatorContext.getFeatures())));
        TestFramework testFramework = generatorContext.getTestFramework();
        String testSourcePath = generatorContext.getTestSourcePath("/{packagePath}/{className}");
        Project project = generatorContext.getProject();
        TestRockerModelProvider provider = new DefaultTestRockerModelProvider(spock.template(project), kotlinJunit.template(project), kotlinJunit.template(project), kotlinJunit.template(project), koTest.template(project));
        generatorContext.addTemplate("applicationTest", new RockerTemplate(testSourcePath, provider.findModel(generatorContext.getLanguage(), testFramework)));
    }
}
Also used : RockerTemplate(io.micronaut.starter.template.RockerTemplate) Project(io.micronaut.starter.application.Project) TestFramework(io.micronaut.starter.options.TestFramework) TestRockerModelProvider(io.micronaut.starter.options.TestRockerModelProvider) DefaultTestRockerModelProvider(io.micronaut.starter.options.DefaultTestRockerModelProvider) DefaultTestRockerModelProvider(io.micronaut.starter.options.DefaultTestRockerModelProvider)

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