From 6ecfd8ee097f919c965bada21440f5a6b58ac4c4 Mon Sep 17 00:00:00 2001 From: Thibault Duperron Date: Sat, 16 Mar 2019 23:01:14 +0100 Subject: [PATCH] Add packageName configuration to maven --- .../org/openapitools/codegen/plugin/CodeGenMojo.java | 10 ++++++++++ .../codegen/config/CodegenConfigurator.java | 11 +++++++++++ 2 files changed, 21 insertions(+) diff --git a/modules/openapi-generator-maven-plugin/src/main/java/org/openapitools/codegen/plugin/CodeGenMojo.java b/modules/openapi-generator-maven-plugin/src/main/java/org/openapitools/codegen/plugin/CodeGenMojo.java index 4bbb3b9c0eb1..710a19335b86 100644 --- a/modules/openapi-generator-maven-plugin/src/main/java/org/openapitools/codegen/plugin/CodeGenMojo.java +++ b/modules/openapi-generator-maven-plugin/src/main/java/org/openapitools/codegen/plugin/CodeGenMojo.java @@ -163,6 +163,12 @@ public class CodeGenMojo extends AbstractMojo { @Parameter(name = "invokerPackage") private String invokerPackage; + /** + * The default package to use for the generated objects + */ + @Parameter(name = "packageName") + private String packageName; + /** * groupId in generated pom.xml */ @@ -510,6 +516,10 @@ public void execute() throws MojoExecutionException { configurator.setInvokerPackage(invokerPackage); } + if (isNotEmpty(packageName)) { + configurator.setPackageName(packageName); + } + if (isNotEmpty(groupId)) { configurator.setGroupId(groupId); } diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/config/CodegenConfigurator.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/config/CodegenConfigurator.java index a1bdb827ea50..36da893f1222 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/config/CodegenConfigurator.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/config/CodegenConfigurator.java @@ -81,6 +81,7 @@ public class CodegenConfigurator implements Serializable { private String apiPackage; private String modelPackage; private String invokerPackage; + private String packageName; private String modelNamePrefix; private String modelNameSuffix; private String groupId; @@ -316,6 +317,15 @@ public CodegenConfigurator setInvokerPackage(String invokerPackage) { return this; } + public String getPackageName() { + return packageName; + } + + public CodegenConfigurator setPackageName(String packageName) { + this.packageName = packageName; + return this; + } + public String getGroupId() { return groupId; } @@ -521,6 +531,7 @@ public ClientOptInput toClientOptInput() { checkAndSetAdditionalProperty(apiPackage, CodegenConstants.API_PACKAGE); checkAndSetAdditionalProperty(modelPackage, CodegenConstants.MODEL_PACKAGE); checkAndSetAdditionalProperty(invokerPackage, CodegenConstants.INVOKER_PACKAGE); + checkAndSetAdditionalProperty(packageName, CodegenConstants.PACKAGE_NAME); checkAndSetAdditionalProperty(groupId, CodegenConstants.GROUP_ID); checkAndSetAdditionalProperty(artifactId, CodegenConstants.ARTIFACT_ID); checkAndSetAdditionalProperty(artifactVersion, CodegenConstants.ARTIFACT_VERSION);