OLD | NEW |
1 package com.google.dart.tools.core.pub; | 1 package com.google.dart.tools.core.pub; |
2 | 2 |
3 import com.google.dart.tools.core.DartCore; | 3 import com.google.dart.tools.core.DartCore; |
4 import com.google.dart.tools.core.MessageConsole; | 4 import com.google.dart.tools.core.MessageConsole; |
5 import com.google.dart.tools.core.dart2js.ProcessRunner; | 5 import com.google.dart.tools.core.dart2js.ProcessRunner; |
6 import com.google.dart.tools.core.model.DartSdk; | 6 import com.google.dart.tools.core.model.DartSdk; |
7 import com.google.dart.tools.core.model.DartSdkManager; | 7 import com.google.dart.tools.core.model.DartSdkManager; |
8 | 8 |
9 import org.eclipse.core.resources.IContainer; | 9 import org.eclipse.core.resources.IContainer; |
10 import org.eclipse.core.resources.IResource; | 10 import org.eclipse.core.resources.IResource; |
11 import org.eclipse.core.resources.IncrementalProjectBuilder; | 11 import org.eclipse.core.resources.IncrementalProjectBuilder; |
12 import org.eclipse.core.runtime.CoreException; | 12 import org.eclipse.core.runtime.CoreException; |
13 import org.eclipse.core.runtime.IProgressMonitor; | 13 import org.eclipse.core.runtime.IProgressMonitor; |
14 import org.eclipse.core.runtime.IStatus; | 14 import org.eclipse.core.runtime.IStatus; |
15 import org.eclipse.core.runtime.OperationCanceledException; | 15 import org.eclipse.core.runtime.OperationCanceledException; |
16 import org.eclipse.core.runtime.Status; | 16 import org.eclipse.core.runtime.Status; |
17 import org.eclipse.core.runtime.jobs.Job; | 17 import org.eclipse.core.runtime.jobs.Job; |
18 import org.eclipse.osgi.util.NLS; | 18 import org.eclipse.osgi.util.NLS; |
19 | 19 |
20 import java.io.File; | 20 import java.io.File; |
21 import java.io.IOException; | 21 import java.io.IOException; |
22 import java.util.ArrayList; | 22 import java.util.ArrayList; |
| 23 import java.util.Arrays; |
23 import java.util.List; | 24 import java.util.List; |
24 | 25 |
25 /** | 26 /** |
26 * Runs the pub operation as an external process. The operation can be scheduled
via the {@link Job} | 27 * Runs the pub operation as an external process. The operation can be scheduled
via the {@link Job} |
27 * infrastructure or executed directly by calling {@link #run(IProgressMonitor)}
or | 28 * infrastructure or executed directly by calling {@link #run(IProgressMonitor)}
or |
28 * {@link #runSilent(IProgressMonitor)} if this operation should not display out
put in the console. | 29 * {@link #runSilent(IProgressMonitor)} if this operation should not display out
put in the console. |
29 * | 30 * |
30 * @coverage dart.tools.core.pub | 31 * @coverage dart.tools.core.pub |
31 */ | 32 */ |
32 public class RunPubJob extends Job { | 33 public class RunPubJob extends Job { |
33 | 34 |
34 public static final String UPDATE_COMMAND = "upgrade"; //$NON-NLS-1$ | 35 public static final String UPDATE_COMMAND = "upgrade"; //$NON-NLS-1$ |
35 public static final String INSTALL_COMMAND = "get"; //$NON-NLS-1$ | 36 public static final String INSTALL_COMMAND = "get"; //$NON-NLS-1$ |
36 public static final String INSTALL_OFFLINE_COMMAND = "get --offline"; //$NON-N
LS-1$ | 37 public static final String INSTALL_OFFLINE_COMMAND = "get --offline"; //$NON-N
LS-1$ |
37 public static final String PUBLISH_COMMAND = "publish"; //$NON-NLS-1$ | 38 public static final String PUBLISH_COMMAND = "publish"; //$NON-NLS-1$ |
38 public static final String DEPLOY_COMMAND = "build"; //$NON-NLS-1$ | 39 public static final String DEPLOY_COMMAND = "build"; //$NON-NLS-1$ |
| 40 public static final String BUILD_NOMINIFY_COMMAND = "build --no-minify"; //$NO
N-NLS-1$ |
39 | 41 |
40 /** | 42 /** |
41 * The pub command to be run (e.g. "install", "update") | 43 * The pub command to be run (e.g. "install", "update") |
42 */ | 44 */ |
43 private final String command; | 45 private final String command; |
44 | 46 |
45 /** | 47 /** |
46 * The directory in which the pub command will be run | 48 * The directory in which the pub command will be run |
47 */ | 49 */ |
48 private final IContainer container; | 50 private final IContainer container; |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 builder.redirectErrorStream(true); | 99 builder.redirectErrorStream(true); |
98 | 100 |
99 List<String> args = new ArrayList<String>(); | 101 List<String> args = new ArrayList<String>(); |
100 if (DartCore.isMac()) { | 102 if (DartCore.isMac()) { |
101 args.add("/bin/bash"); | 103 args.add("/bin/bash"); |
102 args.add("--login"); | 104 args.add("--login"); |
103 args.add("-c"); | 105 args.add("-c"); |
104 args.add("\"" + pubFile.getAbsolutePath() + "\"" + " " + command); | 106 args.add("\"" + pubFile.getAbsolutePath() + "\"" + " " + command); |
105 } else { | 107 } else { |
106 args.add(pubFile.getAbsolutePath()); | 108 args.add(pubFile.getAbsolutePath()); |
107 args.add(command); | 109 if (command.contains(" ")) { |
| 110 String[] strings = command.split(" "); |
| 111 args.addAll(Arrays.asList(strings)); |
| 112 } else { |
| 113 args.add(command); |
| 114 } |
108 } | 115 } |
109 builder.command(args); | 116 builder.command(args); |
110 | 117 |
111 // Run the pub command as an external process. | 118 // Run the pub command as an external process. |
112 runner = newProcessRunner(builder); | 119 runner = newProcessRunner(builder); |
113 | 120 |
114 try { | 121 try { |
115 runner.runSync(monitor); | 122 runner.runSync(monitor); |
116 } catch (IOException e) { | 123 } catch (IOException e) { |
117 String message = NLS.bind(PubMessages.RunPubJob_failed, command, e.toStr
ing()); | 124 String message = NLS.bind(PubMessages.RunPubJob_failed, command, e.toStr
ing()); |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
165 * testing this class to prevent from actually running pub. | 172 * testing this class to prevent from actually running pub. |
166 * | 173 * |
167 * @param builder the process description (not {@code null}) | 174 * @param builder the process description (not {@code null}) |
168 * @return the process runner (not {@code null}) | 175 * @return the process runner (not {@code null}) |
169 */ | 176 */ |
170 protected ProcessRunner newProcessRunner(ProcessBuilder builder) { | 177 protected ProcessRunner newProcessRunner(ProcessBuilder builder) { |
171 return new ProcessRunner(builder); | 178 return new ProcessRunner(builder); |
172 } | 179 } |
173 | 180 |
174 } | 181 } |
OLD | NEW |