This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

View | Details | Raw Unified | Return to bug 97335
Collapse All | Expand All

(-)projects/src/org/netbeans/modules/ruby/rubyproject/RubyActionProvider.java (+4 lines)
Lines 32-37 Link Here
32
import java.util.ArrayList;
32
import java.util.ArrayList;
33
import java.util.Arrays;
33
import java.util.Arrays;
34
import java.util.Collection;
34
import java.util.Collection;
35
import java.util.HashMap;
35
import java.util.HashSet;
36
import java.util.HashSet;
36
import java.util.LinkedHashSet;
37
import java.util.LinkedHashSet;
37
import java.util.List;
38
import java.util.List;
Lines 240-245 Link Here
240
            }
241
            }
241
        }
242
        }
243
        Map<String, String> env = new HashMap<String, String>();
244
        env.put("CLASSPATH", "c:\\work\\nbprj\\javalib1\\dist\\javalib1.jar");
242
        new RubyExecutionService(displayName, pwd, target).
245
        new RubyExecutionService(displayName, pwd, target).
243
                showSuspended(true).
246
                showSuspended(true).
244
                allowInput().
247
                allowInput().
Lines 247-252 Link Here
247
                additionalArgs(applicationArgs).
250
                additionalArgs(applicationArgs).
248
                fileLocator(new RubyFileLocator(context)).
251
                fileLocator(new RubyFileLocator(context)).
249
                addOutputRecognizer(RegexpOutputRecognizer.RUBY_COMPILER).
252
                addOutputRecognizer(RegexpOutputRecognizer.RUBY_COMPILER).
253
                setEnvironment(env).
250
                run();
254
                run();
251
    }
255
    }
(-)projects/src/org/netbeans/modules/ruby/rubyproject/api/RubyExecutionService.java (-25 / +47 lines)
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);
(-)railsprojects/src/org/netbeans/modules/ruby/railsprojects/server/WebrickServer.java (+5 lines)
Lines 22-27 Link Here
22
import java.awt.event.ActionEvent;
22
import java.awt.event.ActionEvent;
23
import java.io.File;
23
import java.io.File;
24
import java.net.URL;
24
import java.net.URL;
25
import java.util.HashMap;
26
import java.util.Map;
25
import javax.swing.AbstractAction;
27
import javax.swing.AbstractAction;
26
import javax.swing.JButton;
28
import javax.swing.JButton;
27
import javax.swing.event.ChangeListener;
29
import javax.swing.event.ChangeListener;
Lines 92-97 Link Here
92
        }
94
        }
93
        portConflict = false;
95
        portConflict = false;
96
        Map<String, String> env = new HashMap<String, String>();
97
        env.put("CLASSPATH", "c:\\work\\nbprj\\javalib1\\dist\\javalib1.jar");
94
        int port = RubyInstallation.getInstance().getRailsPort();
98
        int port = RubyInstallation.getInstance().getRailsPort();
95
        new RubyExecutionService(NbBundle.getMessage(RuntimeNode.class, "WEBrick"), dir,
99
        new RubyExecutionService(NbBundle.getMessage(RuntimeNode.class, "WEBrick"), dir,
96
            "script" + File.separator + "server", "--port", Integer.toString(port)).postBuild(finishedAction) // NOI18N
100
            "script" + File.separator + "server", "--port", Integer.toString(port)).postBuild(finishedAction) // NOI18N
Lines 99-104 Link Here
99
               .addOutputRecognizer(new WebrickMessageListener())
103
               .addOutputRecognizer(new WebrickMessageListener())
100
               .fileLocator(new DirectoryFileLocator(FileUtil.toFileObject(dir)))
104
               .fileLocator(new DirectoryFileLocator(FileUtil.toFileObject(dir)))
101
               .showProgress(false)
105
               .showProgress(false)
106
               .setEnvironment(env)
102
               .run();
107
               .run();
103
    }
108
    }

Return to bug 97335