Lines 32-39
Link Here
|
32 |
import java.io.StringWriter; |
32 |
import java.io.StringWriter; |
33 |
import java.lang.InterruptedException; |
33 |
import java.lang.InterruptedException; |
34 |
import java.util.ArrayList; |
34 |
import java.util.ArrayList; |
|
|
35 |
import java.util.HashMap; |
35 |
import java.util.List; |
36 |
import java.util.List; |
36 |
import java.util.Map; |
37 |
import java.util.Map; |
|
|
38 |
import java.util.logging.Level; |
39 |
import java.util.logging.Logger; |
37 |
import javax.swing.AbstractAction; |
40 |
import javax.swing.AbstractAction; |
38 |
import javax.swing.SwingUtilities; |
41 |
import javax.swing.SwingUtilities; |
39 |
import javax.swing.text.Document; |
42 |
import javax.swing.text.Document; |
Lines 112-123
Link Here
|
112 |
private Runnable postBuildAction; |
115 |
private Runnable postBuildAction; |
113 |
private FileLocator fileLocator; |
116 |
private FileLocator fileLocator; |
114 |
private String[] args; |
117 |
private String[] args; |
|
|
118 |
private Map<String, String> env = new HashMap<String, String>(); |
115 |
private String additionalArgs; |
119 |
private String additionalArgs; |
116 |
private String initialArgs; |
120 |
private String initialArgs; |
117 |
private boolean showProgress = true; |
121 |
private boolean showProgress = true; |
118 |
private boolean showSuspended; |
122 |
private boolean showSuspended; |
119 |
private List<OutputRecognizer> outputRecognizers = new ArrayList<OutputRecognizer>(); |
123 |
private List<OutputRecognizer> outputRecognizers = new ArrayList<OutputRecognizer>(); |
|
|
124 |
private static final Logger LOGGER = Logger.getLogger(RubyExecutionService.class.getName()); |
125 |
|
120 |
public RubyExecutionService(final String displayName, final File pwd, final String... args) { |
126 |
public RubyExecutionService(final String displayName, final File pwd, final String... args) { |
121 |
this.displayName = displayName; |
127 |
this.displayName = displayName; |
122 |
this.pwd = pwd; |
128 |
this.pwd = pwd; |
Lines 156-161
Link Here
|
156 |
return this; |
162 |
return this; |
157 |
} |
163 |
} |
|
|
164 |
public RubyExecutionService setEnvironment(Map <String, String> entries) { |
165 |
env = entries; |
166 |
|
167 |
return this; |
168 |
} |
169 |
|
158 |
public RubyExecutionService showProgress(boolean showProgress) { |
170 |
public RubyExecutionService showProgress(boolean showProgress) { |
159 |
this.showProgress = showProgress; |
171 |
this.showProgress = showProgress; |
Lines 182-219
Link Here
|
182 |
return this; |
194 |
return this; |
183 |
} |
195 |
} |
184 |
/** Add settings in the environment appropriate for running JRuby: |
196 |
private static void mergeEnvironmentEntries(Map<String, String> env, Map<String, String> newEntries) { |
185 |
add the given directory into the path, and set up JRUBY_HOME |
|
|
186 |
*/ |
187 |
public static void setupEnvironment(ProcessBuilder pb, String path) { |
188 |
|
189 |
// Get source folders |
190 |
Map<String, String> env = pb.environment(); |
191 |
|
192 |
// Find PATH environment variable - on Windows it can be some other |
197 |
// Find PATH environment variable - on Windows it can be some other |
193 |
// case and we should use whatever it has. |
198 |
// case and we should use whatever it has. |
194 |
String pathName = "PATH"; // NOI18N |
199 |
for (String newKey : newEntries.keySet()) { |
195 |
if (Utilities.isWindows()) { |
200 |
String varName = newKey; |
196 |
pathName = "Path"; // NOI18N |
201 |
if (Utilities.isWindows()) { |
197 |
for (String key : env.keySet()) { |
202 |
for (String key : env.keySet()) { |
198 |
if ("PATH".equals(key.toUpperCase())) { // NOI18N |
203 |
String upperCase = newKey.toUpperCase(); |
199 |
pathName = key; |
204 |
if (upperCase.equals(key.toUpperCase())) { // NOI18N |
200 |
break; |
205 |
varName = key; |
|
|
206 |
break; |
207 |
} |
201 |
} |
208 |
} |
202 |
} |
209 |
} |
203 |
} |
210 |
String currentValue = env.get(varName); |
204 |
String currentPath = env.get(pathName); |
|
|
205 |
if (currentPath == null) { |
211 |
if (currentValue == null) { |
206 |
currentPath = ""; |
212 |
currentValue = ""; |
207 |
} |
213 |
} |
208 |
if (!Utilities.isWindows()) { |
214 |
String value = newEntries.get(newKey); |
209 |
path = path.replace(" ", "\\ "); // NOI18N |
215 |
if (!Utilities.isWindows()) { |
|
|
216 |
value = value.replace(" ", "\\ "); // NOI18N |
217 |
} |
218 |
value = value + File.pathSeparator + currentValue; |
219 |
env.put(varName, value); // NOI18N |
210 |
} |
220 |
} |
211 |
currentPath = path + File.pathSeparator + currentPath; |
221 |
} |
212 |
env.put(pathName, currentPath); // NOI18N |
222 |
|
|
|
223 |
/** Add settings in the environment appropriate for running JRuby: |
224 |
add the given directory into the path, and set up JRUBY_HOME |
225 |
*/ |
226 |
public static void setupEnvironment(ProcessBuilder pb, String path) { |
227 |
|
228 |
// Get source folders |
229 |
Map<String, String> env = pb.environment(); |
230 |
|
231 |
Map<String, String> pathEnv = new HashMap<String, String>(); |
232 |
pathEnv.put(Utilities.isWindows() ? "Path" : "PATH", path); //NOI18N |
233 |
mergeEnvironmentEntries(env, pathEnv); |
213 |
// In case we're launching JRuby: |
234 |
// In case we're launching JRuby: |
214 |
String jrubyHome = RubyInstallation.getInstance().getJRubyHome(); |
235 |
String jrubyHome = RubyInstallation.getInstance().getJRubyHome(); |
Lines 286-292
Link Here
|
286 |
pb.directory(pwd); |
307 |
pb.directory(pwd); |
287 |
setupEnvironment(pb, cmd.getParent()); |
308 |
setupEnvironment(pb, cmd.getParent()); |
288 |
|
309 |
mergeEnvironmentEntries(pb.environment(), env); |
|
|
310 |
|
289 |
try { |
311 |
try { |
290 |
Process process = pb.start(); |
312 |
Process process = pb.start(); |
291 |
runIO(process, io, fileLocator, outputRecognizers); |
313 |
runIO(process, io, fileLocator, outputRecognizers); |