From a7229397ecc765d951f34d7729e25070a7b585ad Mon Sep 17 00:00:00 2001 From: HugoMario Date: Fri, 22 May 2020 10:56:07 -0500 Subject: [PATCH] added option to skip support files on micronaut generator --- .../v3/generators/java/MicronautCodegen.java | 22 +++++++++++++------ 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/src/main/java/io/swagger/codegen/v3/generators/java/MicronautCodegen.java b/src/main/java/io/swagger/codegen/v3/generators/java/MicronautCodegen.java index 686406a926..d14588646b 100644 --- a/src/main/java/io/swagger/codegen/v3/generators/java/MicronautCodegen.java +++ b/src/main/java/io/swagger/codegen/v3/generators/java/MicronautCodegen.java @@ -35,6 +35,7 @@ public class MicronautCodegen extends AbstractJavaCodegen implements BeanValidat private static final String BASE_PACKAGE = "basePackage"; private static final String USE_TAGS = "useTags"; private static final String IMPLICIT_HEADERS = "implicitHeaders"; + private static final String SKIP_SUPPORT_FILES = "skipSupportFiles"; private String title = "swagger-petstore"; private String configPackage = "io.swagger.configuration"; @@ -66,6 +67,7 @@ private void init() { cliOptions.add(new CliOption(TITLE, "server title name or client service name")); cliOptions.add(new CliOption(CONFIG_PACKAGE, "configuration package for generated code")); cliOptions.add(new CliOption(BASE_PACKAGE, "base package (invokerPackage) for generated code")); + cliOptions.add(new CliOption(SKIP_SUPPORT_FILES, "skip support files such as pom.xml, mvnw, etc from code generation.")); cliOptions.add(CliOption.newBoolean(USE_TAGS, "use tags for creating interface and controller classnames")); cliOptions.add(CliOption.newBoolean(USE_BEANVALIDATION, "Use BeanValidation API annotations")); cliOptions.add(CliOption.newBoolean(IMPLICIT_HEADERS, "Use of @ApiImplicitParams for headers.")); @@ -152,6 +154,11 @@ public void processOpts() { this.setUseOptional(convertPropertyToBoolean(USE_OPTIONAL)); } + boolean skipSupportFiles = false; + if (additionalProperties.containsKey(SKIP_SUPPORT_FILES)) { + skipSupportFiles = Boolean.valueOf(additionalProperties.get(SKIP_SUPPORT_FILES).toString()); + } + if (useBeanValidation) { writePropertyBack(USE_BEANVALIDATION, useBeanValidation); } @@ -164,14 +171,15 @@ public void processOpts() { writePropertyBack(USE_OPTIONAL, useOptional); } - supportingFiles.add(new SupportingFile("pom.mustache", "", "pom.xml")); - supportingFiles.add(new SupportingFile("README.mustache", "", "README.md")); - supportingFiles.add(new SupportingFile("mvnw", "", "mvnw")); - supportingFiles.add(new SupportingFile("mvnw.cmd", "", "mvnw.cmd")); - supportingFiles.add(new SupportingFile("unsupportedOperationExceptionHandler.mustache", + if (!skipSupportFiles) { + supportingFiles.add(new SupportingFile("pom.mustache", "", "pom.xml")); + supportingFiles.add(new SupportingFile("README.mustache", "", "README.md")); + supportingFiles.add(new SupportingFile("mvnw", "", "mvnw")); + supportingFiles.add(new SupportingFile("mvnw.cmd", "", "mvnw.cmd")); + supportingFiles.add(new SupportingFile("unsupportedOperationExceptionHandler.mustache", (sourceFolder + File.separator + configPackage).replace(".", File.separator), "UnsupportedOperationExceptionHandler.java")); - supportingFiles.add(new SupportingFile("mainApplication.mustache", (sourceFolder + File.separator).replace(".", File.separator), "MainApplication.java")); - + supportingFiles.add(new SupportingFile("mainApplication.mustache", (sourceFolder + File.separator).replace(".", File.separator), "MainApplication.java")); + } addHandlebarsLambdas(additionalProperties); }