Search in sources :

Example 11 with Project

use of io.micronaut.starter.application.Project in project micronaut-starter by micronaut-projects.

the class CreateCommand method call.

@Override
public Integer call() throws Exception {
    if (listFeatures) {
        new ListFeatures(availableFeatures, new Options(lang, test, build, getJdkVersion()), applicationType, getOperatingSystem(), contextFactory).output(this);
        return 0;
    }
    Project project;
    try {
        project = NameUtils.parse(name);
    } catch (IllegalArgumentException e) {
        throw new CommandLine.ParameterException(this.spec.commandLine(), StringUtils.isEmpty(name) ? "Specify an application name or use --inplace to create an application in the current directory" : e.getMessage());
    }
    OutputHandler outputHandler = new FileSystemOutputHandler(project, inplace, this);
    generate(project, outputHandler);
    out("@|blue ||@ Application created at " + outputHandler.getOutputLocation());
    return 0;
}
Also used : Project(io.micronaut.starter.application.Project) CommandLine(picocli.CommandLine) FileSystemOutputHandler(io.micronaut.starter.io.FileSystemOutputHandler) OutputHandler(io.micronaut.starter.io.OutputHandler) FileSystemOutputHandler(io.micronaut.starter.io.FileSystemOutputHandler)

Example 12 with Project

use of io.micronaut.starter.application.Project 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 13 with Project

use of io.micronaut.starter.application.Project in project micronaut-starter by micronaut-projects.

the class AwsLambda method apply.

@Override
public void apply(GeneratorContext generatorContext) {
    Project project = generatorContext.getProject();
    if (shouldGenerateSources(generatorContext)) {
        addBook(generatorContext, project);
        addBookSaved(generatorContext, project);
        ApplicationType applicationType = generatorContext.getApplicationType();
        if (applicationType == DEFAULT || applicationType == FUNCTION) {
            if (applicationType == DEFAULT) {
                addBookController(generatorContext, project);
                addBookControllerTest(generatorContext, project);
            } else {
                addRequestHandler(generatorContext, project);
                addTest(generatorContext, project);
            }
            DocumentationLink link = new DocumentationLink(LINK_TITLE, LINK_URL);
            generatorContext.addHelpTemplate(new RockerWritable(readmeRockerModel(this, generatorContext, link)));
        }
    }
}
Also used : Project(io.micronaut.starter.application.Project) ApplicationType(io.micronaut.starter.application.ApplicationType) RockerWritable(io.micronaut.starter.template.RockerWritable) DocumentationLink(io.micronaut.starter.feature.function.DocumentationLink)

Example 14 with Project

use of io.micronaut.starter.application.Project in project micronaut-starter by micronaut-projects.

the class OracleRawFunction method apply.

@Override
public void apply(GeneratorContext generatorContext) {
    ApplicationType type = generatorContext.getApplicationType();
    if (type == ApplicationType.FUNCTION) {
        applyFunction(generatorContext, type);
        Language language = generatorContext.getLanguage();
        Project project = generatorContext.getProject();
        String sourceFile = generatorContext.getSourcePath("/{packagePath}/Function");
        switch(language) {
            case GROOVY:
                generatorContext.addTemplate("function", new RockerTemplate(sourceFile, oracleRawFunctionGroovy.template(project)));
                break;
            case KOTLIN:
                generatorContext.addTemplate("function", new RockerTemplate(sourceFile, oracleRawFunctionKotlin.template(project)));
                break;
            case JAVA:
            default:
                generatorContext.addTemplate("function", new RockerTemplate(sourceFile, oracleRawFunctionJava.template(project)));
        }
        applyTestTemplate(generatorContext, project, "Function");
    }
}
Also used : RockerTemplate(io.micronaut.starter.template.RockerTemplate) ApplicationType(io.micronaut.starter.application.ApplicationType) Project(io.micronaut.starter.application.Project) Language(io.micronaut.starter.options.Language)

Example 15 with Project

use of io.micronaut.starter.application.Project in project micronaut-starter by micronaut-projects.

the class GoogleCloudRawFunction method apply.

@Override
public void apply(GeneratorContext generatorContext) {
    ApplicationType type = generatorContext.getApplicationType();
    applyFunction(generatorContext, type);
    if (type == ApplicationType.FUNCTION) {
        Language language = generatorContext.getLanguage();
        Project project = generatorContext.getProject();
        String sourceFile = generatorContext.getSourcePath("/{packagePath}/Function");
        switch(language) {
            case GROOVY:
                generatorContext.addTemplate("function", new RockerTemplate(sourceFile, gcpRawBackgroundFunctionGroovy.template(project)));
                break;
            case KOTLIN:
                generatorContext.addTemplate("function", new RockerTemplate(sourceFile, gcpRawBackgroundFunctionKotlin.template(project)));
                break;
            case JAVA:
            default:
                generatorContext.addTemplate("function", new RockerTemplate(sourceFile, gcpRawBackgroundFunctionJava.template(project)));
        }
        applyTestTemplate(generatorContext, project, "Function");
    }
}
Also used : RockerTemplate(io.micronaut.starter.template.RockerTemplate) ApplicationType(io.micronaut.starter.application.ApplicationType) Project(io.micronaut.starter.application.Project) Language(io.micronaut.starter.options.Language)

Aggregations

Project (io.micronaut.starter.application.Project)36 RockerTemplate (io.micronaut.starter.template.RockerTemplate)23 RenderResult (io.micronaut.starter.template.RenderResult)17 TemplateRenderer (io.micronaut.starter.template.TemplateRenderer)17 RockerModel (com.fizzed.rocker.RockerModel)12 ApplicationType (io.micronaut.starter.application.ApplicationType)7 TestRockerModelProvider (io.micronaut.starter.options.TestRockerModelProvider)7 DefaultTestRockerModelProvider (io.micronaut.starter.options.DefaultTestRockerModelProvider)6 Language (io.micronaut.starter.options.Language)5 HttpStatusException (io.micronaut.http.exceptions.HttpStatusException)4 Options (io.micronaut.starter.options.Options)4 Get (io.micronaut.http.annotation.Get)3 GeneratorContext (io.micronaut.starter.application.generator.GeneratorContext)3 ProjectGenerator (io.micronaut.starter.application.generator.ProjectGenerator)3 TestFramework (io.micronaut.starter.options.TestFramework)3 MapOutputHandler (io.micronaut.starter.io.MapOutputHandler)2 OutputHandler (io.micronaut.starter.io.OutputHandler)2 BuildTool (io.micronaut.starter.options.BuildTool)2 RockerWritable (io.micronaut.starter.template.RockerWritable)2 ApiResponse (io.swagger.v3.oas.annotations.responses.ApiResponse)2