From 3eb42e7183e70fe68c754edb9cccfc0fc05a5545 Mon Sep 17 00:00:00 2001 From: Jan Bartel Date: Fri, 3 Oct 2014 14:27:35 +1000 Subject: [PATCH] 445830 Support setting environment variables on forked jetty with jetty:run-forked --- .../jetty/maven/plugin/JettyRunForkedMojo.java | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/JettyRunForkedMojo.java b/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/JettyRunForkedMojo.java index 97b7219ca08..cc2d67f723a 100644 --- a/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/JettyRunForkedMojo.java +++ b/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/JettyRunForkedMojo.java @@ -30,10 +30,12 @@ import java.io.OutputStream; import java.net.MalformedURLException; import java.util.ArrayList; import java.util.Arrays; +import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; import java.util.List; import java.util.Locale; +import java.util.Map; import java.util.Properties; import java.util.Random; import java.util.Set; @@ -137,6 +139,14 @@ public class JettyRunForkedMojo extends JettyRunMojo * @parameter default-value="50" */ private int maxStartupLines; + + + /** + * Extra environment variables to be passed to the forked process + * + * @parameter + */ + private Map env = new HashMap(); /** * The forked jetty instance @@ -344,7 +354,13 @@ public class JettyRunForkedMojo extends JettyRunMojo PluginLog.getLog().debug(Arrays.toString(cmd.toArray())); PluginLog.getLog().info("Forked process starting"); - + + //set up extra environment vars if there are any + if (!env.isEmpty()) + { + builder.environment().putAll(env); + } + if (waitForChild) { forkedProcess = builder.start();