use of io.micronaut.starter.api.event.ApplicationGeneratingEvent in project micronaut-starter by micronaut-projects.
the class AbstractCreateController method createProjectGeneratorContext.
public GeneratorContext createProjectGeneratorContext(ApplicationType type, @Pattern(regexp = "[\\w\\d-_\\.]+") String name, @Nullable List<String> features, @Nullable BuildTool buildTool, @Nullable TestFramework testFramework, @Nullable Language lang, @Nullable JdkVersion javaVersion, @Nullable @Header(HttpHeaders.USER_AGENT) String userAgent) {
Project project;
try {
project = NameUtils.parse(name);
} catch (IllegalArgumentException e) {
throw new HttpStatusException(HttpStatus.BAD_REQUEST, "Invalid project name: " + e.getMessage());
}
GeneratorContext generatorContext;
try {
generatorContext = projectGenerator.createGeneratorContext(type, project, new Options(lang, testFramework != null ? testFramework.toTestFramework() : null, buildTool == null ? BuildTool.GRADLE : buildTool, javaVersion != null ? javaVersion : JdkVersion.JDK_8), getOperatingSystem(userAgent), features != null ? features : Collections.emptyList(), ConsoleOutput.NOOP);
try {
eventPublisher.publishEvent(new ApplicationGeneratingEvent(generatorContext));
} catch (Exception e) {
LOG.warn("Error firing application generated event: " + e.getMessage(), e);
}
} catch (IllegalArgumentException e) {
throw new HttpStatusException(HttpStatus.BAD_REQUEST, e.getMessage());
}
return generatorContext;
}
Aggregations