Search in sources :

Example 1 with OutputHandler

use of io.micronaut.starter.io.OutputHandler 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 2 with OutputHandler

use of io.micronaut.starter.io.OutputHandler in project micronaut-starter by micronaut-projects.

the class GitHubCreateService method generateAppLocally.

/**
 * Generates the micronaut application into specified {@code repoPath} directory
 *
 * @param generatorContext context
 * @param repoPath         path
 * @throws IOException
 */
protected void generateAppLocally(@NotNull GeneratorContext generatorContext, @NotNull Path repoPath) throws IOException {
    try {
        if (!Files.isDirectory(repoPath)) {
            throw new IllegalArgumentException(String.format("The path %s must be a directory!", repoPath.toString()));
        }
        OutputHandler outputHandler = new FileSystemOutputHandler(repoPath.toFile(), ConsoleOutput.NOOP);
        projectGenerator.generate(generatorContext.getApplicationType(), generatorContext.getProject(), outputHandler, generatorContext);
    } catch (Exception e) {
        LOG.error("Error generating application: " + e.getMessage(), e);
        throw new IOException(e.getMessage(), e);
    }
}
Also used : FileSystemOutputHandler(io.micronaut.starter.io.FileSystemOutputHandler) IOException(java.io.IOException) OutputHandler(io.micronaut.starter.io.OutputHandler) FileSystemOutputHandler(io.micronaut.starter.io.FileSystemOutputHandler) HttpClientResponseException(io.micronaut.http.client.exceptions.HttpClientResponseException) GitAPIException(org.eclipse.jgit.api.errors.GitAPIException) IOException(java.io.IOException)

Aggregations

FileSystemOutputHandler (io.micronaut.starter.io.FileSystemOutputHandler)2 OutputHandler (io.micronaut.starter.io.OutputHandler)2 HttpClientResponseException (io.micronaut.http.client.exceptions.HttpClientResponseException)1 Project (io.micronaut.starter.application.Project)1 IOException (java.io.IOException)1 GitAPIException (org.eclipse.jgit.api.errors.GitAPIException)1 CommandLine (picocli.CommandLine)1