From 9f842a1295b97549eecdce540b8e112a0b993ce3 Mon Sep 17 00:00:00 2001 From: Tony Tam Date: Thu, 22 Oct 2015 14:34:52 -0700 Subject: [PATCH] added environment variable support --- .../java/io/swagger/codegen/plugin/CodeGenMojo.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/modules/swagger-codegen-maven-plugin/src/main/java/io/swagger/codegen/plugin/CodeGenMojo.java b/modules/swagger-codegen-maven-plugin/src/main/java/io/swagger/codegen/plugin/CodeGenMojo.java index 21eef59b010..805afe22a94 100644 --- a/modules/swagger-codegen-maven-plugin/src/main/java/io/swagger/codegen/plugin/CodeGenMojo.java +++ b/modules/swagger-codegen-maven-plugin/src/main/java/io/swagger/codegen/plugin/CodeGenMojo.java @@ -36,6 +36,7 @@ import config.Config; import config.ConfigParser; import java.io.File; +import java.util.HashMap; import java.util.Map; import java.util.ServiceLoader; @@ -112,6 +113,9 @@ public class CodeGenMojo extends AbstractMojo { @Parameter(defaultValue = "true") private boolean addCompileSourceRoot = true; + @Parameter + protected Map environmentVariables = new HashMap(); + /** * The project being built. */ @@ -125,6 +129,12 @@ public class CodeGenMojo extends AbstractMojo { CodegenConfig config = CodegenConfigLoader.forName(language); config.setOutputDir(output.getAbsolutePath()); + if (environmentVariables != null) { + for(String key : environmentVariables.keySet()) { + System.setProperty(key, environmentVariables.get(key)); + } + } + if (null != templateDirectory) { config.additionalProperties().put(TEMPLATE_DIR_PARAM, templateDirectory.getAbsolutePath()); }