Skip to content

Commit 9f842a1

Browse files
committed
added environment variable support
1 parent 723cf9b commit 9f842a1

File tree

1 file changed

+10
-0
lines changed
  • modules/swagger-codegen-maven-plugin/src/main/java/io/swagger/codegen/plugin

1 file changed

+10
-0
lines changed

modules/swagger-codegen-maven-plugin/src/main/java/io/swagger/codegen/plugin/CodeGenMojo.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
import config.ConfigParser;
3737

3838
import java.io.File;
39+
import java.util.HashMap;
3940
import java.util.Map;
4041
import java.util.ServiceLoader;
4142

@@ -112,6 +113,9 @@ public class CodeGenMojo extends AbstractMojo {
112113
@Parameter(defaultValue = "true")
113114
private boolean addCompileSourceRoot = true;
114115

116+
@Parameter
117+
protected Map<String, String> environmentVariables = new HashMap<String, String>();
118+
115119
/**
116120
* The project being built.
117121
*/
@@ -125,6 +129,12 @@ public void execute() throws MojoExecutionException {
125129
CodegenConfig config = CodegenConfigLoader.forName(language);
126130
config.setOutputDir(output.getAbsolutePath());
127131

132+
if (environmentVariables != null) {
133+
for(String key : environmentVariables.keySet()) {
134+
System.setProperty(key, environmentVariables.get(key));
135+
}
136+
}
137+
128138
if (null != templateDirectory) {
129139
config.additionalProperties().put(TEMPLATE_DIR_PARAM, templateDirectory.getAbsolutePath());
130140
}

0 commit comments

Comments
 (0)