|
Lines 1-761
Link Here
|
| 1 |
/******************************************************************************* |
1 |
///******************************************************************************* |
| 2 |
* Copyright (c) 2000, 2009 IBM Corporation and others. |
2 |
// * Copyright (c) 2000, 2009 IBM Corporation and others. |
| 3 |
* All rights reserved. This program and the accompanying materials |
3 |
// * All rights reserved. This program and the accompanying materials |
| 4 |
* are made available under the terms of the Eclipse Public License v1.0 |
4 |
// * are made available under the terms of the Eclipse Public License v1.0 |
| 5 |
* which accompanies this distribution, and is available at |
5 |
// * which accompanies this distribution, and is available at |
| 6 |
* http://www.eclipse.org/legal/epl-v10.html |
6 |
// * http://www.eclipse.org/legal/epl-v10.html |
| 7 |
* |
7 |
// * |
| 8 |
* Contributors: |
8 |
// * Contributors: |
| 9 |
* IBM Corporation - initial API and implementation |
9 |
// * IBM Corporation - initial API and implementation |
| 10 |
* Juan A. Hernandez - bug 89926 |
10 |
// * Juan A. Hernandez - bug 89926 |
| 11 |
* dakshinamurthy.karra@gmail.com - bug 165371 |
11 |
// * dakshinamurthy.karra@gmail.com - bug 165371 |
| 12 |
*******************************************************************************/ |
12 |
// *******************************************************************************/ |
| 13 |
package org.eclipse.ant.internal.ui.launchConfigurations; |
13 |
//package org.eclipse.ant.internal.ui.launchConfigurations; |
| 14 |
|
14 |
// |
| 15 |
import java.io.File; |
15 |
//import java.io.File; |
| 16 |
import java.io.IOException; |
16 |
//import java.io.IOException; |
| 17 |
import java.net.URL; |
17 |
//import java.net.URL; |
| 18 |
import java.util.HashMap; |
18 |
//import java.util.HashMap; |
| 19 |
import java.util.Iterator; |
19 |
//import java.util.Iterator; |
| 20 |
import java.util.List; |
20 |
//import java.util.List; |
| 21 |
import java.util.Map; |
21 |
//import java.util.Map; |
| 22 |
|
22 |
// |
| 23 |
import org.apache.tools.ant.ProjectHelper; |
23 |
//import org.apache.tools.ant.ProjectHelper; |
| 24 |
import org.eclipse.ant.core.AntCorePlugin; |
24 |
//import org.eclipse.ant.core.AntCorePlugin; |
| 25 |
import org.eclipse.ant.core.AntCorePreferences; |
25 |
//import org.eclipse.ant.core.AntCorePreferences; |
| 26 |
import org.eclipse.ant.core.AntRunner; |
26 |
//import org.eclipse.ant.core.AntRunner; |
| 27 |
import org.eclipse.ant.core.Property; |
27 |
//import org.eclipse.ant.core.Property; |
| 28 |
import org.eclipse.ant.core.Task; |
28 |
//import org.eclipse.ant.core.Task; |
| 29 |
import org.eclipse.ant.core.Type; |
29 |
//import org.eclipse.ant.core.Type; |
| 30 |
import org.eclipse.ant.internal.core.AbstractEclipseBuildLogger; |
30 |
//import org.eclipse.ant.internal.core.AbstractEclipseBuildLogger; |
| 31 |
import org.eclipse.ant.internal.ui.AntUIPlugin; |
31 |
//import org.eclipse.ant.internal.launching.AntLaunchingUtil; |
| 32 |
import org.eclipse.ant.internal.ui.AntUtil; |
32 |
//import org.eclipse.ant.internal.ui.AntUIPlugin; |
| 33 |
import org.eclipse.ant.internal.ui.IAntUIConstants; |
33 |
//import org.eclipse.ant.internal.ui.AntUtil; |
| 34 |
import org.eclipse.ant.internal.ui.IAntUIPreferenceConstants; |
34 |
//import org.eclipse.ant.internal.ui.IAntUIConstants; |
| 35 |
import org.eclipse.ant.internal.ui.debug.IAntDebugConstants; |
35 |
//import org.eclipse.ant.internal.ui.IAntUIPreferenceConstants; |
| 36 |
import org.eclipse.ant.internal.ui.debug.model.RemoteAntDebugBuildListener; |
36 |
//import org.eclipse.ant.internal.ui.debug.IAntDebugConstants; |
| 37 |
import org.eclipse.ant.ui.launching.IAntLaunchConfigurationConstants; |
37 |
//import org.eclipse.ant.internal.ui.debug.model.RemoteAntDebugBuildListener; |
| 38 |
import org.eclipse.core.resources.IProject; |
38 |
//import org.eclipse.ant.ui.launching.IAntLaunchConfigurationConstants; |
| 39 |
import org.eclipse.core.runtime.CoreException; |
39 |
//import org.eclipse.core.resources.IProject; |
| 40 |
import org.eclipse.core.runtime.FileLocator; |
40 |
//import org.eclipse.core.runtime.CoreException; |
| 41 |
import org.eclipse.core.runtime.IPath; |
41 |
//import org.eclipse.core.runtime.FileLocator; |
| 42 |
import org.eclipse.core.runtime.IProgressMonitor; |
42 |
//import org.eclipse.core.runtime.IPath; |
| 43 |
import org.eclipse.core.runtime.IStatus; |
43 |
//import org.eclipse.core.runtime.IProgressMonitor; |
| 44 |
import org.eclipse.core.runtime.Path; |
44 |
//import org.eclipse.core.runtime.IStatus; |
| 45 |
import org.eclipse.core.runtime.Platform; |
45 |
//import org.eclipse.core.runtime.Path; |
| 46 |
import org.eclipse.core.runtime.Status; |
46 |
//import org.eclipse.core.runtime.Platform; |
| 47 |
import org.eclipse.core.runtime.SubProgressMonitor; |
47 |
//import org.eclipse.core.runtime.Status; |
| 48 |
import org.eclipse.core.variables.VariablesPlugin; |
48 |
//import org.eclipse.core.runtime.SubProgressMonitor; |
| 49 |
import org.eclipse.debug.core.DebugEvent; |
49 |
//import org.eclipse.core.variables.VariablesPlugin; |
| 50 |
import org.eclipse.debug.core.DebugPlugin; |
50 |
//import org.eclipse.debug.core.DebugEvent; |
| 51 |
import org.eclipse.debug.core.IBreakpointManager; |
51 |
//import org.eclipse.debug.core.DebugPlugin; |
| 52 |
import org.eclipse.debug.core.IDebugEventSetListener; |
52 |
//import org.eclipse.debug.core.IBreakpointManager; |
| 53 |
import org.eclipse.debug.core.ILaunch; |
53 |
//import org.eclipse.debug.core.IDebugEventSetListener; |
| 54 |
import org.eclipse.debug.core.ILaunchConfiguration; |
54 |
//import org.eclipse.debug.core.ILaunch; |
| 55 |
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; |
55 |
//import org.eclipse.debug.core.ILaunchConfiguration; |
| 56 |
import org.eclipse.debug.core.ILaunchManager; |
56 |
//import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; |
| 57 |
import org.eclipse.debug.core.model.IBreakpoint; |
57 |
//import org.eclipse.debug.core.ILaunchManager; |
| 58 |
import org.eclipse.debug.core.model.IProcess; |
58 |
//import org.eclipse.debug.core.model.IBreakpoint; |
| 59 |
import org.eclipse.debug.core.model.LaunchConfigurationDelegate; |
59 |
//import org.eclipse.debug.core.model.IProcess; |
| 60 |
import org.eclipse.debug.ui.CommonTab; |
60 |
//import org.eclipse.debug.core.model.LaunchConfigurationDelegate; |
| 61 |
import org.eclipse.debug.ui.IDebugUIConstants; |
61 |
//import org.eclipse.debug.ui.CommonTab; |
| 62 |
import org.eclipse.debug.ui.RefreshTab; |
62 |
//import org.eclipse.debug.ui.IDebugUIConstants; |
| 63 |
import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants; |
63 |
//import org.eclipse.debug.ui.RefreshTab; |
| 64 |
import org.eclipse.jdt.launching.IVMInstall; |
64 |
//import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants; |
| 65 |
import org.eclipse.jdt.launching.JavaRuntime; |
65 |
//import org.eclipse.jdt.launching.IVMInstall; |
| 66 |
import org.eclipse.jdt.launching.SocketUtil; |
66 |
//import org.eclipse.jdt.launching.JavaRuntime; |
| 67 |
import org.eclipse.jface.dialogs.MessageDialogWithToggle; |
67 |
//import org.eclipse.jdt.launching.SocketUtil; |
| 68 |
import org.eclipse.jface.preference.IPreferenceStore; |
68 |
//import org.eclipse.jface.dialogs.MessageDialogWithToggle; |
| 69 |
import org.eclipse.osgi.service.resolver.BundleDescription; |
69 |
//import org.eclipse.jface.preference.IPreferenceStore; |
| 70 |
import org.eclipse.ui.externaltools.internal.launchConfigurations.ExternalToolsBuildTab; |
70 |
//import org.eclipse.osgi.service.resolver.BundleDescription; |
| 71 |
import org.eclipse.ui.externaltools.internal.launchConfigurations.ExternalToolsUtil; |
71 |
//import org.eclipse.ui.externaltools.internal.launchConfigurations.ExternalToolsBuildTab; |
| 72 |
import org.eclipse.ui.externaltools.internal.model.IExternalToolConstants; |
72 |
//import org.eclipse.ui.externaltools.internal.launchConfigurations.ExternalToolsUtil; |
| 73 |
import org.eclipse.ui.externaltools.internal.program.launchConfigurations.BackgroundResourceRefresher; |
73 |
//import org.eclipse.ui.externaltools.internal.model.IExternalToolConstants; |
| 74 |
import org.osgi.framework.Bundle; |
74 |
//import org.eclipse.ui.externaltools.internal.program.launchConfigurations.BackgroundResourceRefresher; |
| 75 |
|
75 |
//import org.osgi.framework.Bundle; |
| 76 |
import com.ibm.icu.text.MessageFormat; |
76 |
// |
| 77 |
|
77 |
//import com.ibm.icu.text.MessageFormat; |
| 78 |
/** |
78 |
// |
| 79 |
* Launch delegate for Ant builds |
79 |
///** |
| 80 |
*/ |
80 |
// * Launch delegate for Ant builds |
| 81 |
public class AntLaunchDelegate extends LaunchConfigurationDelegate { |
81 |
// */ |
| 82 |
|
82 |
//public class AntLaunchDelegate extends LaunchConfigurationDelegate { |
| 83 |
private static final String ANT_LOGGER_CLASS = "org.eclipse.ant.internal.ui.antsupport.logger.AntProcessBuildLogger"; //$NON-NLS-1$ |
83 |
// |
| 84 |
private static final String ANT_DEBUG_LOGGER_CLASS = "org.eclipse.ant.internal.ui.antsupport.logger.AntProcessDebugBuildLogger"; //$NON-NLS-1$ |
84 |
// private static final String ANT_LOGGER_CLASS = "org.eclipse.ant.internal.ui.antsupport.logger.AntProcessBuildLogger"; //$NON-NLS-1$ |
| 85 |
private static final String NULL_LOGGER_CLASS = "org.eclipse.ant.internal.ui.antsupport.logger.NullBuildLogger"; //$NON-NLS-1$ |
85 |
// private static final String ANT_DEBUG_LOGGER_CLASS = "org.eclipse.ant.internal.ui.antsupport.logger.AntProcessDebugBuildLogger"; //$NON-NLS-1$ |
| 86 |
private static final String REMOTE_ANT_LOGGER_CLASS = "org.eclipse.ant.internal.ui.antsupport.logger.RemoteAntBuildLogger"; //$NON-NLS-1$ |
86 |
// private static final String NULL_LOGGER_CLASS = "org.eclipse.ant.internal.ui.antsupport.logger.NullBuildLogger"; //$NON-NLS-1$ |
| 87 |
private static final String REMOTE_ANT_DEBUG_LOGGER_CLASS = "org.eclipse.ant.internal.ui.antsupport.logger.debug.RemoteAntDebugBuildLogger"; //$NON-NLS-1$ |
87 |
// private static final String REMOTE_ANT_LOGGER_CLASS = "org.eclipse.ant.internal.ui.antsupport.logger.RemoteAntBuildLogger"; //$NON-NLS-1$ |
| 88 |
private static final String BASE_DIR_PREFIX = "-Dbasedir="; //$NON-NLS-1$ |
88 |
// private static final String REMOTE_ANT_DEBUG_LOGGER_CLASS = "org.eclipse.ant.internal.ui.antsupport.logger.debug.RemoteAntDebugBuildLogger"; //$NON-NLS-1$ |
| 89 |
private static final String INPUT_HANDLER_CLASS = "org.eclipse.ant.internal.ui.antsupport.inputhandler.AntInputHandler"; //$NON-NLS-1$ |
89 |
// private static final String BASE_DIR_PREFIX = "-Dbasedir="; //$NON-NLS-1$ |
| 90 |
private static final String REMOTE_INPUT_HANDLER_CLASS = "org.eclipse.ant.internal.ui.antsupport.inputhandler.ProxyInputHandler"; //$NON-NLS-1$ |
90 |
// private static final String INPUT_HANDLER_CLASS = "org.eclipse.ant.internal.ui.antsupport.inputhandler.AntInputHandler"; //$NON-NLS-1$ |
| 91 |
|
91 |
// private static final String REMOTE_INPUT_HANDLER_CLASS = "org.eclipse.ant.internal.ui.antsupport.inputhandler.ProxyInputHandler"; //$NON-NLS-1$ |
| 92 |
private static final IProject[] NO_PROJECTS = new IProject[0]; |
92 |
// |
| 93 |
|
93 |
// private static final IProject[] NO_PROJECTS = new IProject[0]; |
| 94 |
/** |
94 |
// |
| 95 |
* String attribute identifying the build scope for a launch configuration. |
95 |
// /** |
| 96 |
* <code>null</code> indicates the default workspace build. |
96 |
// * String attribute identifying the build scope for a launch configuration. |
| 97 |
*/ |
97 |
// * <code>null</code> indicates the default workspace build. |
| 98 |
private static final String ATTR_BUILD_SCOPE = AntUIPlugin.getUniqueIdentifier() + ".ATTR_BUILD_SCOPE"; //$NON-NLS-1$ |
98 |
// */ |
| 99 |
|
99 |
// private static final String ATTR_BUILD_SCOPE = AntUIPlugin.getUniqueIdentifier() + ".ATTR_BUILD_SCOPE"; //$NON-NLS-1$ |
| 100 |
/** |
100 |
// |
| 101 |
* Attribute identifier specifying whether referenced projects should be |
101 |
// /** |
| 102 |
* considered when computing the projects to build. Default value is |
102 |
// * Attribute identifier specifying whether referenced projects should be |
| 103 |
* <code>true</code>. |
103 |
// * considered when computing the projects to build. Default value is |
| 104 |
*/ |
104 |
// * <code>true</code>. |
| 105 |
private static final String ATTR_INCLUDE_REFERENCED_PROJECTS = AntUIPlugin.getUniqueIdentifier() + ".ATTR_INCLUDE_REFERENCED_PROJECTS"; //$NON-NLS-1$ |
105 |
// */ |
| 106 |
|
106 |
// private static final String ATTR_INCLUDE_REFERENCED_PROJECTS = AntUIPlugin.getUniqueIdentifier() + ".ATTR_INCLUDE_REFERENCED_PROJECTS"; //$NON-NLS-1$ |
| 107 |
|
107 |
// |
| 108 |
private static String fgSWTLibraryLocation; |
108 |
// |
| 109 |
|
109 |
// private static String fgSWTLibraryLocation; |
| 110 |
private String fMode; |
110 |
// |
| 111 |
private boolean fUserSpecifiedLogger= false; |
111 |
// private String fMode; |
| 112 |
|
112 |
// private boolean fUserSpecifiedLogger= false; |
| 113 |
private String getProgramArguments(ILaunchConfiguration configuration) throws CoreException { |
113 |
// |
| 114 |
String arguments = configuration.getAttribute(IExternalToolConstants.ATTR_TOOL_ARGUMENTS, ""); //$NON-NLS-1$ |
114 |
// private String getProgramArguments(ILaunchConfiguration configuration) throws CoreException { |
| 115 |
return VariablesPlugin.getDefault().getStringVariableManager().performStringSubstitution(arguments); |
115 |
// String arguments = configuration.getAttribute(IExternalToolConstants.ATTR_TOOL_ARGUMENTS, ""); //$NON-NLS-1$ |
| 116 |
} |
116 |
// return VariablesPlugin.getDefault().getStringVariableManager().performStringSubstitution(arguments); |
| 117 |
|
117 |
// } |
| 118 |
/** |
118 |
// |
| 119 |
* @see org.eclipse.debug.core.model.ILaunchConfigurationDelegate#launch(org.eclipse.debug.core.ILaunchConfiguration, |
119 |
// /** |
| 120 |
* java.lang.String, org.eclipse.debug.core.ILaunch, |
120 |
// * @see org.eclipse.debug.core.model.ILaunchConfigurationDelegate#launch(org.eclipse.debug.core.ILaunchConfiguration, |
| 121 |
* org.eclipse.core.runtime.IProgressMonitor) |
121 |
// * java.lang.String, org.eclipse.debug.core.ILaunch, |
| 122 |
*/ |
122 |
// * org.eclipse.core.runtime.IProgressMonitor) |
| 123 |
public void launch(ILaunchConfiguration configuration, String mode, ILaunch launch, IProgressMonitor monitor) throws CoreException { |
123 |
// */ |
| 124 |
if (monitor.isCanceled()) { |
124 |
// public void launch(ILaunchConfiguration configuration, String mode, ILaunch launch, IProgressMonitor monitor) throws CoreException { |
| 125 |
return; |
125 |
// if (monitor.isCanceled()) { |
| 126 |
} |
126 |
// return; |
| 127 |
fUserSpecifiedLogger= false; |
127 |
// } |
| 128 |
fMode= mode; |
128 |
// fUserSpecifiedLogger= false; |
| 129 |
|
129 |
// fMode= mode; |
| 130 |
// migrate the config to the new classpath format if required |
130 |
// |
| 131 |
AntUtil.migrateToNewClasspathFormat(configuration); |
131 |
// // migrate the config to the new classpath format if required |
| 132 |
|
132 |
// AntLaunchingUtil.migrateToNewClasspathFormat(configuration); |
| 133 |
boolean isSeparateJRE= AntUtil.isSeparateJREAntBuild(configuration); |
133 |
// |
| 134 |
|
134 |
// boolean isSeparateJRE= AntLaunchingUtil.isSeparateJREAntBuild(configuration); |
| 135 |
if (CommonTab.isLaunchInBackground(configuration)) { |
135 |
// |
| 136 |
monitor.beginTask(MessageFormat.format(AntLaunchConfigurationMessages.AntLaunchDelegate_Launching__0__1, new String[] {configuration.getName()}), 10); |
136 |
// if (CommonTab.isLaunchInBackground(configuration)) { |
| 137 |
} else { |
137 |
// monitor.beginTask(MessageFormat.format(AntLaunchConfigurationMessages.AntLaunchDelegate_Launching__0__1, new String[] {configuration.getName()}), 10); |
| 138 |
monitor.beginTask(MessageFormat.format(AntLaunchConfigurationMessages.AntLaunchDelegate_Running__0__2, new String[] {configuration.getName()}), 100); |
138 |
// } else { |
| 139 |
} |
139 |
// monitor.beginTask(MessageFormat.format(AntLaunchConfigurationMessages.AntLaunchDelegate_Running__0__2, new String[] {configuration.getName()}), 100); |
| 140 |
|
140 |
// } |
| 141 |
// resolve location |
141 |
// |
| 142 |
IPath location = ExternalToolsUtil.getLocation(configuration); |
142 |
// // resolve location |
| 143 |
monitor.worked(1); |
143 |
// IPath location = ExternalToolsUtil.getLocation(configuration); |
| 144 |
|
144 |
// monitor.worked(1); |
| 145 |
if (monitor.isCanceled()) { |
145 |
// |
| 146 |
return; |
146 |
// if (monitor.isCanceled()) { |
| 147 |
} |
147 |
// return; |
| 148 |
|
148 |
// } |
| 149 |
if (!isSeparateJRE && AntRunner.isBuildRunning()) { |
149 |
// |
| 150 |
IStatus status= new Status(IStatus.ERROR, IAntUIConstants.PLUGIN_ID, 1, MessageFormat.format(AntLaunchConfigurationMessages.AntLaunchDelegate_Build_In_Progress, new String[]{location.toOSString()}), null); |
150 |
// if (!isSeparateJRE && AntRunner.isBuildRunning()) { |
| 151 |
throw new CoreException(status); |
151 |
// IStatus status= new Status(IStatus.ERROR, IAntUIConstants.PLUGIN_ID, 1, MessageFormat.format(AntLaunchConfigurationMessages.AntLaunchDelegate_Build_In_Progress, new String[]{location.toOSString()}), null); |
| 152 |
} |
152 |
// throw new CoreException(status); |
| 153 |
|
153 |
// } |
| 154 |
// resolve working directory |
154 |
// |
| 155 |
IPath workingDirectory = ExternalToolsUtil.getWorkingDirectory(configuration); |
155 |
// // resolve working directory |
| 156 |
String basedir = null; |
156 |
// IPath workingDirectory = ExternalToolsUtil.getWorkingDirectory(configuration); |
| 157 |
if (workingDirectory != null) { |
157 |
// String basedir = null; |
| 158 |
basedir= workingDirectory.toOSString(); |
158 |
// if (workingDirectory != null) { |
| 159 |
} |
159 |
// basedir= workingDirectory.toOSString(); |
| 160 |
monitor.worked(1); |
160 |
// } |
| 161 |
|
161 |
// monitor.worked(1); |
| 162 |
if (monitor.isCanceled()) { |
162 |
// |
| 163 |
return; |
163 |
// if (monitor.isCanceled()) { |
| 164 |
} |
164 |
// return; |
| 165 |
|
165 |
// } |
| 166 |
// link the process to its build logger via a timestamp |
166 |
// |
| 167 |
long timeStamp = System.currentTimeMillis(); |
167 |
// // link the process to its build logger via a timestamp |
| 168 |
String idStamp = Long.toString(timeStamp); |
168 |
// long timeStamp = System.currentTimeMillis(); |
| 169 |
StringBuffer idProperty = new StringBuffer("-D"); //$NON-NLS-1$ |
169 |
// String idStamp = Long.toString(timeStamp); |
| 170 |
idProperty.append(AbstractEclipseBuildLogger.ANT_PROCESS_ID); |
170 |
// StringBuffer idProperty = new StringBuffer("-D"); //$NON-NLS-1$ |
| 171 |
idProperty.append('='); |
171 |
// idProperty.append(AbstractEclipseBuildLogger.ANT_PROCESS_ID); |
| 172 |
idProperty.append(idStamp); |
172 |
// idProperty.append('='); |
| 173 |
|
173 |
// idProperty.append(idStamp); |
| 174 |
// resolve arguments |
174 |
// |
| 175 |
String[] arguments = null; |
175 |
// // resolve arguments |
| 176 |
if (isSeparateJRE) { |
176 |
// String[] arguments = null; |
| 177 |
arguments = new String[] {getProgramArguments(configuration)}; |
177 |
// if (isSeparateJRE) { |
| 178 |
} else { |
178 |
// arguments = new String[] {getProgramArguments(configuration)}; |
| 179 |
arguments = ExternalToolsUtil.getArguments(configuration); |
179 |
// } else { |
| 180 |
} |
180 |
// arguments = ExternalToolsUtil.getArguments(configuration); |
| 181 |
|
181 |
// } |
| 182 |
Map userProperties= AntUtil.getProperties(configuration); |
182 |
// |
| 183 |
if (userProperties != null) {//create a copy so as to not affect the configuration with transient properties |
183 |
// Map userProperties= AntLaunchingUtil.getProperties(configuration); |
| 184 |
userProperties= new HashMap(userProperties); |
184 |
// if (userProperties != null) {//create a copy so as to not affect the configuration with transient properties |
| 185 |
} |
185 |
// userProperties= new HashMap(userProperties); |
| 186 |
String[] propertyFiles= AntUtil.getPropertyFiles(configuration); |
186 |
// } |
| 187 |
String[] targets = AntUtil.getTargetNames(configuration); |
187 |
// String[] propertyFiles= AntUtil.getPropertyFiles(configuration); |
| 188 |
URL[] customClasspath= AntUtil.getCustomClasspath(configuration); |
188 |
// String[] targets = AntLaunchingUtil.getTargetNames(configuration); |
| 189 |
String antHome= AntUtil.getAntHome(configuration); |
189 |
// URL[] customClasspath= AntLaunchingUtil.getCustomClasspath(configuration); |
| 190 |
|
190 |
// String antHome= AntLaunchingUtil.getAntHome(configuration); |
| 191 |
boolean setInputHandler= true; |
191 |
// |
| 192 |
try { |
192 |
// boolean setInputHandler= true; |
| 193 |
//check if set specify inputhandler |
193 |
// try { |
| 194 |
setInputHandler = configuration.getAttribute(IAntUIConstants.SET_INPUTHANDLER, true); |
194 |
// //check if set specify inputhandler |
| 195 |
} catch (CoreException ce) { |
195 |
// setInputHandler = configuration.getAttribute(IAntUIConstants.SET_INPUTHANDLER, true); |
| 196 |
AntUIPlugin.log(ce); |
196 |
// } catch (CoreException ce) { |
| 197 |
} |
197 |
// AntUIPlugin.log(ce); |
| 198 |
|
198 |
// } |
| 199 |
AntRunner runner= null; |
199 |
// |
| 200 |
if (!isSeparateJRE) { |
200 |
// AntRunner runner= null; |
| 201 |
runner = configureAntRunner(configuration, location, basedir, idProperty, arguments, userProperties, propertyFiles, targets, customClasspath, antHome, setInputHandler); |
201 |
// if (!isSeparateJRE) { |
| 202 |
} |
202 |
// runner = configureAntRunner(configuration, location, basedir, idProperty, arguments, userProperties, propertyFiles, targets, customClasspath, antHome, setInputHandler); |
| 203 |
|
203 |
// } |
| 204 |
monitor.worked(1); |
204 |
// |
| 205 |
|
205 |
// monitor.worked(1); |
| 206 |
if (monitor.isCanceled()) { |
206 |
// |
| 207 |
return; |
207 |
// if (monitor.isCanceled()) { |
| 208 |
} |
208 |
// return; |
| 209 |
boolean captureOutput= ExternalToolsUtil.getCaptureOutput(configuration); |
209 |
// } |
| 210 |
int port= -1; |
210 |
// boolean captureOutput= ExternalToolsUtil.getCaptureOutput(configuration); |
| 211 |
int requestPort= -1; |
211 |
// int port= -1; |
| 212 |
if (isSeparateJRE && captureOutput) { |
212 |
// int requestPort= -1; |
| 213 |
if (userProperties == null) { |
213 |
// if (isSeparateJRE && captureOutput) { |
| 214 |
userProperties= new HashMap(); |
214 |
// if (userProperties == null) { |
| 215 |
} |
215 |
// userProperties= new HashMap(); |
| 216 |
port= SocketUtil.findFreePort(); |
216 |
// } |
| 217 |
userProperties.put(AbstractEclipseBuildLogger.ANT_PROCESS_ID, idStamp); |
217 |
// port= SocketUtil.findFreePort(); |
| 218 |
userProperties.put("eclipse.connect.port", Integer.toString(port)); //$NON-NLS-1$ |
218 |
// userProperties.put(AbstractEclipseBuildLogger.ANT_PROCESS_ID, idStamp); |
| 219 |
if (fMode.equals(ILaunchManager.DEBUG_MODE)) { |
219 |
// userProperties.put("eclipse.connect.port", Integer.toString(port)); //$NON-NLS-1$ |
| 220 |
requestPort= SocketUtil.findFreePort(); |
220 |
// if (fMode.equals(ILaunchManager.DEBUG_MODE)) { |
| 221 |
userProperties.put("eclipse.connect.request_port", Integer.toString(requestPort)); //$NON-NLS-1$ |
221 |
// requestPort= SocketUtil.findFreePort(); |
| 222 |
} |
222 |
// userProperties.put("eclipse.connect.request_port", Integer.toString(requestPort)); //$NON-NLS-1$ |
| 223 |
} |
223 |
// } |
| 224 |
|
224 |
// } |
| 225 |
StringBuffer commandLine= generateCommandLine(location, arguments, userProperties, propertyFiles, targets, antHome, basedir, isSeparateJRE, captureOutput, setInputHandler); |
225 |
// |
| 226 |
|
226 |
// StringBuffer commandLine= generateCommandLine(location, arguments, userProperties, propertyFiles, targets, antHome, basedir, isSeparateJRE, captureOutput, setInputHandler); |
| 227 |
if (isSeparateJRE) { |
227 |
// |
| 228 |
monitor.beginTask(MessageFormat.format(AntLaunchConfigurationMessages.AntLaunchDelegate_Launching__0__1, new String[] {configuration.getName()}), 10); |
228 |
// if (isSeparateJRE) { |
| 229 |
runInSeparateVM(configuration, launch, monitor, idStamp, antHome, port, requestPort, commandLine, captureOutput, setInputHandler); |
229 |
// monitor.beginTask(MessageFormat.format(AntLaunchConfigurationMessages.AntLaunchDelegate_Launching__0__1, new String[] {configuration.getName()}), 10); |
| 230 |
} else { |
230 |
// runInSeparateVM(configuration, launch, monitor, idStamp, antHome, port, requestPort, commandLine, captureOutput, setInputHandler); |
| 231 |
runInSameVM(configuration, launch, monitor, location, idStamp, runner, commandLine, captureOutput); |
231 |
// } else { |
| 232 |
} |
232 |
// runInSameVM(configuration, launch, monitor, location, idStamp, runner, commandLine, captureOutput); |
| 233 |
|
233 |
// } |
| 234 |
monitor.done(); |
234 |
// |
| 235 |
} |
235 |
// monitor.done(); |
| 236 |
|
236 |
// } |
| 237 |
private void runInSameVM(ILaunchConfiguration configuration, ILaunch launch, IProgressMonitor monitor, IPath location, String idStamp, AntRunner runner, StringBuffer commandLine, boolean captureOutput) throws CoreException { |
237 |
// |
| 238 |
Map attributes= new HashMap(2); |
238 |
// private void runInSameVM(ILaunchConfiguration configuration, ILaunch launch, IProgressMonitor monitor, IPath location, String idStamp, AntRunner runner, StringBuffer commandLine, boolean captureOutput) throws CoreException { |
| 239 |
attributes.put(IProcess.ATTR_PROCESS_TYPE, IAntLaunchConfigurationConstants.ID_ANT_PROCESS_TYPE); |
239 |
// Map attributes= new HashMap(2); |
| 240 |
attributes.put(AbstractEclipseBuildLogger.ANT_PROCESS_ID, idStamp); |
240 |
// attributes.put(IProcess.ATTR_PROCESS_TYPE, IAntLaunchConfigurationConstants.ID_ANT_PROCESS_TYPE); |
| 241 |
|
241 |
// attributes.put(AbstractEclipseBuildLogger.ANT_PROCESS_ID, idStamp); |
| 242 |
final AntProcess process = new AntProcess(location.toOSString(), launch, attributes); |
242 |
// |
| 243 |
setProcessAttributes(process, idStamp, commandLine, captureOutput); |
243 |
// final AntProcess process = new AntProcess(location.toOSString(), launch, attributes); |
| 244 |
boolean debug= fMode.equals(ILaunchManager.DEBUG_MODE); |
244 |
// setProcessAttributes(process, idStamp, commandLine, captureOutput); |
| 245 |
if (debug || CommonTab.isLaunchInBackground(configuration)) { |
245 |
// boolean debug= fMode.equals(ILaunchManager.DEBUG_MODE); |
| 246 |
final AntRunner finalRunner= runner; |
246 |
// if (debug || CommonTab.isLaunchInBackground(configuration)) { |
| 247 |
Runnable r = new Runnable() { |
247 |
// final AntRunner finalRunner= runner; |
| 248 |
public void run() { |
248 |
// Runnable r = new Runnable() { |
| 249 |
try { |
249 |
// public void run() { |
| 250 |
finalRunner.run(process); |
250 |
// try { |
| 251 |
} catch (CoreException e) { |
251 |
// finalRunner.run(process); |
| 252 |
handleException(e, AntLaunchConfigurationMessages.AntLaunchDelegate_Failure); |
252 |
// } catch (CoreException e) { |
| 253 |
} |
253 |
// handleException(e, AntLaunchConfigurationMessages.AntLaunchDelegate_Failure); |
| 254 |
process.terminated(); |
254 |
// } |
| 255 |
} |
255 |
// process.terminated(); |
| 256 |
}; |
256 |
// } |
| 257 |
Thread background = new Thread(r); |
257 |
// }; |
| 258 |
background.setDaemon(true); |
258 |
// Thread background = new Thread(r); |
| 259 |
background.start(); |
259 |
// background.setDaemon(true); |
| 260 |
monitor.worked(1); |
260 |
// background.start(); |
| 261 |
//refresh resources after process finishes |
261 |
// monitor.worked(1); |
| 262 |
if (RefreshTab.getRefreshScope(configuration) != null) { |
262 |
// //refresh resources after process finishes |
| 263 |
BackgroundResourceRefresher refresher = new BackgroundResourceRefresher(configuration, process); |
263 |
// if (RefreshTab.getRefreshScope(configuration) != null) { |
| 264 |
refresher.startBackgroundRefresh(); |
264 |
// BackgroundResourceRefresher refresher = new BackgroundResourceRefresher(configuration, process); |
| 265 |
} |
265 |
// refresher.startBackgroundRefresh(); |
| 266 |
} else { |
266 |
// } |
| 267 |
// execute the build |
267 |
// } else { |
| 268 |
try { |
268 |
// // execute the build |
| 269 |
runner.run(monitor); |
269 |
// try { |
| 270 |
} catch (CoreException e) { |
270 |
// runner.run(monitor); |
| 271 |
process.terminated(); |
271 |
// } catch (CoreException e) { |
| 272 |
monitor.done(); |
272 |
// process.terminated(); |
| 273 |
handleException(e, AntLaunchConfigurationMessages.AntLaunchDelegate_23); |
273 |
// monitor.done(); |
| 274 |
return; |
274 |
// handleException(e, AntLaunchConfigurationMessages.AntLaunchDelegate_23); |
| 275 |
} |
275 |
// return; |
| 276 |
process.terminated(); |
276 |
// } |
| 277 |
|
277 |
// process.terminated(); |
| 278 |
// refresh resources |
278 |
// |
| 279 |
RefreshTab.refreshResources(configuration, monitor); |
279 |
// // refresh resources |
| 280 |
} |
280 |
// RefreshTab.refreshResources(configuration, monitor); |
| 281 |
} |
281 |
// } |
| 282 |
|
282 |
// } |
| 283 |
private AntRunner configureAntRunner(ILaunchConfiguration configuration, IPath location, String baseDir, StringBuffer idProperty, String[] arguments, Map userProperties, String[] propertyFiles, String[] targets, URL[] customClasspath, String antHome, boolean setInputHandler) throws CoreException { |
283 |
// |
| 284 |
int argLength = 1; // at least one user property - timestamp |
284 |
// private AntRunner configureAntRunner(ILaunchConfiguration configuration, IPath location, String baseDir, StringBuffer idProperty, String[] arguments, Map userProperties, String[] propertyFiles, String[] targets, URL[] customClasspath, String antHome, boolean setInputHandler) throws CoreException { |
| 285 |
if (arguments != null) { |
285 |
// int argLength = 1; // at least one user property - timestamp |
| 286 |
argLength += arguments.length; |
286 |
// if (arguments != null) { |
| 287 |
} |
287 |
// argLength += arguments.length; |
| 288 |
if (baseDir != null && baseDir.length() > 0) { |
288 |
// } |
| 289 |
argLength++; |
289 |
// if (baseDir != null && baseDir.length() > 0) { |
| 290 |
} |
290 |
// argLength++; |
| 291 |
String[] runnerArgs = new String[argLength]; |
291 |
// } |
| 292 |
if (arguments != null) { |
292 |
// String[] runnerArgs = new String[argLength]; |
| 293 |
System.arraycopy(arguments, 0, runnerArgs, 0, arguments.length); |
293 |
// if (arguments != null) { |
| 294 |
} |
294 |
// System.arraycopy(arguments, 0, runnerArgs, 0, arguments.length); |
| 295 |
if (baseDir != null && baseDir.length() > 0) { |
295 |
// } |
| 296 |
runnerArgs[runnerArgs.length - 2] = BASE_DIR_PREFIX + baseDir; |
296 |
// if (baseDir != null && baseDir.length() > 0) { |
| 297 |
} |
297 |
// runnerArgs[runnerArgs.length - 2] = BASE_DIR_PREFIX + baseDir; |
| 298 |
runnerArgs[runnerArgs.length -1] = idProperty.toString(); |
298 |
// } |
| 299 |
|
299 |
// runnerArgs[runnerArgs.length -1] = idProperty.toString(); |
| 300 |
AntRunner runner= new AntRunner(); |
300 |
// |
| 301 |
runner.setBuildFileLocation(location.toOSString()); |
301 |
// AntRunner runner= new AntRunner(); |
| 302 |
boolean captureOutput= ExternalToolsUtil.getCaptureOutput(configuration); |
302 |
// runner.setBuildFileLocation(location.toOSString()); |
| 303 |
if (captureOutput) { |
303 |
// boolean captureOutput= ExternalToolsUtil.getCaptureOutput(configuration); |
| 304 |
if (fMode.equals(ILaunchManager.DEBUG_MODE)) { |
304 |
// if (captureOutput) { |
| 305 |
runner.addBuildLogger(ANT_DEBUG_LOGGER_CLASS); |
305 |
// if (fMode.equals(ILaunchManager.DEBUG_MODE)) { |
| 306 |
} else { |
306 |
// runner.addBuildLogger(ANT_DEBUG_LOGGER_CLASS); |
| 307 |
runner.addBuildLogger(ANT_LOGGER_CLASS); |
307 |
// } else { |
| 308 |
} |
308 |
// runner.addBuildLogger(ANT_LOGGER_CLASS); |
| 309 |
} else { |
309 |
// } |
| 310 |
runner.addBuildLogger(NULL_LOGGER_CLASS); |
310 |
// } else { |
| 311 |
} |
311 |
// runner.addBuildLogger(NULL_LOGGER_CLASS); |
| 312 |
if (setInputHandler) { |
312 |
// } |
| 313 |
runner.setInputHandler(INPUT_HANDLER_CLASS); |
313 |
// if (setInputHandler) { |
| 314 |
} else { |
314 |
// runner.setInputHandler(INPUT_HANDLER_CLASS); |
| 315 |
runner.setInputHandler(""); //$NON-NLS-1$ |
315 |
// } else { |
| 316 |
} |
316 |
// runner.setInputHandler(""); //$NON-NLS-1$ |
| 317 |
runner.setArguments(runnerArgs); |
317 |
// } |
| 318 |
if (userProperties != null) { |
318 |
// runner.setArguments(runnerArgs); |
| 319 |
runner.addUserProperties(userProperties); |
319 |
// if (userProperties != null) { |
| 320 |
} |
320 |
// runner.addUserProperties(userProperties); |
| 321 |
|
321 |
// } |
| 322 |
if (propertyFiles != null) { |
322 |
// |
| 323 |
runner.setPropertyFiles(propertyFiles); |
323 |
// if (propertyFiles != null) { |
| 324 |
} |
324 |
// runner.setPropertyFiles(propertyFiles); |
| 325 |
|
325 |
// } |
| 326 |
if (targets != null) { |
326 |
// |
| 327 |
runner.setExecutionTargets(targets); |
327 |
// if (targets != null) { |
| 328 |
} |
328 |
// runner.setExecutionTargets(targets); |
| 329 |
|
329 |
// } |
| 330 |
if (customClasspath != null) { |
330 |
// |
| 331 |
runner.setCustomClasspath(customClasspath); |
331 |
// if (customClasspath != null) { |
| 332 |
} |
332 |
// runner.setCustomClasspath(customClasspath); |
| 333 |
|
333 |
// } |
| 334 |
if (antHome != null) { |
334 |
// |
| 335 |
runner.setAntHome(antHome); |
335 |
// if (antHome != null) { |
| 336 |
} |
336 |
// runner.setAntHome(antHome); |
| 337 |
return runner; |
337 |
// } |
| 338 |
} |
338 |
// return runner; |
| 339 |
|
339 |
// } |
| 340 |
private void handleException(final CoreException e, final String title) { |
340 |
// |
| 341 |
IPreferenceStore store= AntUIPlugin.getDefault().getPreferenceStore(); |
341 |
// private void handleException(final CoreException e, final String title) { |
| 342 |
if (store.getBoolean(IAntUIPreferenceConstants.ANT_ERROR_DIALOG)) { |
342 |
// IPreferenceStore store= AntUIPlugin.getDefault().getPreferenceStore(); |
| 343 |
AntUIPlugin.getStandardDisplay().asyncExec(new Runnable() { |
343 |
// if (store.getBoolean(IAntUIPreferenceConstants.ANT_ERROR_DIALOG)) { |
| 344 |
public void run() { |
344 |
// AntUIPlugin.getStandardDisplay().asyncExec(new Runnable() { |
| 345 |
MessageDialogWithToggle.openError(null, title, e.getMessage(), AntLaunchConfigurationMessages.AntLaunchDelegate_22, false, AntUIPlugin.getDefault().getPreferenceStore(), IAntUIPreferenceConstants.ANT_ERROR_DIALOG); |
345 |
// public void run() { |
| 346 |
} |
346 |
// MessageDialogWithToggle.openError(null, title, e.getMessage(), AntLaunchConfigurationMessages.AntLaunchDelegate_22, false, AntUIPlugin.getDefault().getPreferenceStore(), IAntUIPreferenceConstants.ANT_ERROR_DIALOG); |
| 347 |
}); |
347 |
// } |
| 348 |
} |
348 |
// }); |
| 349 |
} |
349 |
// } |
| 350 |
|
350 |
// } |
| 351 |
private void setProcessAttributes(IProcess process, String idStamp, StringBuffer commandLine, boolean captureOutput) { |
351 |
// |
| 352 |
// link the process to the Eclipse build logger via a timestamp |
352 |
// private void setProcessAttributes(IProcess process, String idStamp, StringBuffer commandLine, boolean captureOutput) { |
| 353 |
if (!fUserSpecifiedLogger) { |
353 |
// // link the process to the Eclipse build logger via a timestamp |
| 354 |
process.setAttribute(AbstractEclipseBuildLogger.ANT_PROCESS_ID, idStamp); |
354 |
// if (!fUserSpecifiedLogger) { |
| 355 |
} |
355 |
// process.setAttribute(AbstractEclipseBuildLogger.ANT_PROCESS_ID, idStamp); |
| 356 |
|
356 |
// } |
| 357 |
// create "fake" command line for the process |
357 |
// |
| 358 |
if (commandLine != null) { |
358 |
// // create "fake" command line for the process |
| 359 |
process.setAttribute(IProcess.ATTR_CMDLINE, commandLine.toString()); |
359 |
// if (commandLine != null) { |
| 360 |
} |
360 |
// process.setAttribute(IProcess.ATTR_CMDLINE, commandLine.toString()); |
| 361 |
if (captureOutput && !fUserSpecifiedLogger) { |
361 |
// } |
| 362 |
TaskLinkManager.registerAntBuild(process); |
362 |
// } |
| 363 |
} |
363 |
// |
| 364 |
} |
364 |
// private StringBuffer generateCommandLine(IPath location, String[] arguments, Map userProperties, String[] propertyFiles, String[] targets, String antHome, String basedir, boolean separateVM, boolean captureOutput, boolean setInputHandler) { |
| 365 |
|
365 |
// StringBuffer commandLine= new StringBuffer(); |
| 366 |
private StringBuffer generateCommandLine(IPath location, String[] arguments, Map userProperties, String[] propertyFiles, String[] targets, String antHome, String basedir, boolean separateVM, boolean captureOutput, boolean setInputHandler) { |
366 |
// |
| 367 |
StringBuffer commandLine= new StringBuffer(); |
367 |
// if (!separateVM) { |
| 368 |
|
368 |
// commandLine.append("ant"); //$NON-NLS-1$ |
| 369 |
if (!separateVM) { |
369 |
// } |
| 370 |
commandLine.append("ant"); //$NON-NLS-1$ |
370 |
// |
| 371 |
} |
371 |
// if (arguments != null) { |
| 372 |
|
372 |
// for (int i = 0; i < arguments.length; i++) { |
| 373 |
if (arguments != null) { |
373 |
// commandLine.append(' '); |
| 374 |
for (int i = 0; i < arguments.length; i++) { |
374 |
// commandLine.append(arguments[i]); |
| 375 |
commandLine.append(' '); |
375 |
// } |
| 376 |
commandLine.append(arguments[i]); |
376 |
// } |
| 377 |
} |
377 |
// |
| 378 |
} |
378 |
// AntCorePreferences prefs= AntCorePlugin.getPlugin().getPreferences(); |
| 379 |
|
379 |
// if (propertyFiles == null) { //global |
| 380 |
AntCorePreferences prefs= AntCorePlugin.getPlugin().getPreferences(); |
380 |
// String[] files= prefs.getCustomPropertyFiles(); |
| 381 |
if (propertyFiles == null) { //global |
381 |
// for (int i = 0; i < files.length; i++) { |
| 382 |
String[] files= prefs.getCustomPropertyFiles(); |
382 |
// String path = files[i]; |
| 383 |
for (int i = 0; i < files.length; i++) { |
383 |
// commandLine.append(" -propertyfile \""); //$NON-NLS-1$ |
| 384 |
String path = files[i]; |
384 |
// commandLine.append(path); |
| 385 |
commandLine.append(" -propertyfile \""); //$NON-NLS-1$ |
385 |
// commandLine.append('\"'); |
| 386 |
commandLine.append(path); |
386 |
// } |
| 387 |
commandLine.append('\"'); |
387 |
// } else {//"local" configuration |
| 388 |
} |
388 |
// for (int i = 0; i < propertyFiles.length; i++) { |
| 389 |
} else {//"local" configuration |
389 |
// String path = propertyFiles[i]; |
| 390 |
for (int i = 0; i < propertyFiles.length; i++) { |
390 |
// commandLine.append(" -propertyfile \""); //$NON-NLS-1$ |
| 391 |
String path = propertyFiles[i]; |
391 |
// commandLine.append(path); |
| 392 |
commandLine.append(" -propertyfile \""); //$NON-NLS-1$ |
392 |
// commandLine.append('\"'); |
| 393 |
commandLine.append(path); |
393 |
// } |
| 394 |
commandLine.append('\"'); |
394 |
// } |
| 395 |
} |
395 |
// //"local" configuration |
| 396 |
} |
396 |
// if (userProperties != null) { |
| 397 |
//"local" configuration |
397 |
// Iterator keys = userProperties.keySet().iterator(); |
| 398 |
if (userProperties != null) { |
398 |
// String key; |
| 399 |
Iterator keys = userProperties.keySet().iterator(); |
399 |
// while (keys.hasNext()) { |
| 400 |
String key; |
400 |
// key= (String)keys.next(); |
| 401 |
while (keys.hasNext()) { |
401 |
// appendProperty(commandLine, key, (String)userProperties.get(key)); |
| 402 |
key= (String)keys.next(); |
402 |
// } |
| 403 |
appendProperty(commandLine, key, (String)userProperties.get(key)); |
403 |
// } |
| 404 |
} |
404 |
// |
| 405 |
} |
405 |
// //global |
| 406 |
|
406 |
// List properties= null; |
| 407 |
//global |
407 |
// if (!separateVM) { |
| 408 |
List properties= null; |
408 |
// properties= prefs.getProperties(); |
| 409 |
if (!separateVM) { |
409 |
// } else { |
| 410 |
properties= prefs.getProperties(); |
410 |
// properties= prefs.getRemoteAntProperties(); |
| 411 |
} else { |
411 |
// } |
| 412 |
properties= prefs.getRemoteAntProperties(); |
412 |
// |
| 413 |
} |
413 |
// //if we have user properties this means that the user has chosen to override the global properties |
| 414 |
|
414 |
// //if in a separate VM and have only two (or three if debug) user properties these are really only Eclipse generated properties |
| 415 |
//if we have user properties this means that the user has chosen to override the global properties |
415 |
// //and the user is still using the global properties |
| 416 |
//if in a separate VM and have only two (or three if debug) user properties these are really only Eclipse generated properties |
416 |
// int numberOfEclipseProperties= 2; |
| 417 |
//and the user is still using the global properties |
417 |
// if (userProperties != null && userProperties.get("eclipse.connect.request_port") != null){ //$NON-NLS-1$ |
| 418 |
int numberOfEclipseProperties= 2; |
418 |
// numberOfEclipseProperties= 3; //debug mode |
| 419 |
if (userProperties != null && userProperties.get("eclipse.connect.request_port") != null){ //$NON-NLS-1$ |
419 |
// } |
| 420 |
numberOfEclipseProperties= 3; //debug mode |
420 |
// boolean useGlobalProperties = userProperties == null || (separateVM && userProperties.size() == numberOfEclipseProperties); |
| 421 |
} |
421 |
// if (useGlobalProperties) { |
| 422 |
boolean useGlobalProperties = userProperties == null || (separateVM && userProperties.size() == numberOfEclipseProperties); |
422 |
// for (Iterator iter = properties.iterator(); iter.hasNext();) { |
| 423 |
if (useGlobalProperties) { |
423 |
// Property property = (Property) iter.next(); |
| 424 |
for (Iterator iter = properties.iterator(); iter.hasNext();) { |
424 |
// String key= property.getName(); |
| 425 |
Property property = (Property) iter.next(); |
425 |
// String value= property.getValue(false); |
| 426 |
String key= property.getName(); |
426 |
// if (value != null) { |
| 427 |
String value= property.getValue(false); |
427 |
// appendProperty(commandLine, key, value); |
| 428 |
if (value != null) { |
428 |
// } |
| 429 |
appendProperty(commandLine, key, value); |
429 |
// } |
| 430 |
} |
430 |
// } |
| 431 |
} |
431 |
// |
| 432 |
} |
432 |
// if (basedir != null && basedir.length() > 0) { |
| 433 |
|
433 |
// appendProperty(commandLine, "basedir", basedir); //$NON-NLS-1$ |
| 434 |
if (basedir != null && basedir.length() > 0) { |
434 |
// } |
| 435 |
appendProperty(commandLine, "basedir", basedir); //$NON-NLS-1$ |
435 |
// |
| 436 |
} |
436 |
// if (antHome != null) { |
| 437 |
|
437 |
// commandLine.append(" \"-Dant.home="); //$NON-NLS-1$ |
| 438 |
if (antHome != null) { |
438 |
// commandLine.append(antHome); |
| 439 |
commandLine.append(" \"-Dant.home="); //$NON-NLS-1$ |
439 |
// commandLine.append('\"'); |
| 440 |
commandLine.append(antHome); |
440 |
// } |
| 441 |
commandLine.append('\"'); |
441 |
// |
| 442 |
} |
442 |
// if (separateVM) { |
| 443 |
|
443 |
// if (commandLine.indexOf("-logger") == -1) { //$NON-NLS-1$ |
| 444 |
if (separateVM) { |
444 |
// if (captureOutput) { |
| 445 |
if (commandLine.indexOf("-logger") == -1) { //$NON-NLS-1$ |
445 |
// commandLine.append(" -logger "); //$NON-NLS-1$ |
| 446 |
if (captureOutput) { |
446 |
// if (fMode.equals(ILaunchManager.DEBUG_MODE)) { |
| 447 |
commandLine.append(" -logger "); //$NON-NLS-1$ |
447 |
// commandLine.append(REMOTE_ANT_DEBUG_LOGGER_CLASS); |
| 448 |
if (fMode.equals(ILaunchManager.DEBUG_MODE)) { |
448 |
// } else { |
| 449 |
commandLine.append(REMOTE_ANT_DEBUG_LOGGER_CLASS); |
449 |
// commandLine.append(REMOTE_ANT_LOGGER_CLASS); |
| 450 |
} else { |
450 |
// } |
| 451 |
commandLine.append(REMOTE_ANT_LOGGER_CLASS); |
451 |
// } |
| 452 |
} |
452 |
// } else { |
| 453 |
} |
453 |
// fUserSpecifiedLogger= true; |
| 454 |
} else { |
454 |
// } |
| 455 |
fUserSpecifiedLogger= true; |
455 |
// if (commandLine.indexOf("-inputhandler") == -1 && setInputHandler) { //$NON-NLS-1$ |
| 456 |
} |
456 |
// commandLine.append(" -inputhandler "); //$NON-NLS-1$ |
| 457 |
if (commandLine.indexOf("-inputhandler") == -1 && setInputHandler) { //$NON-NLS-1$ |
457 |
// commandLine.append(REMOTE_INPUT_HANDLER_CLASS); |
| 458 |
commandLine.append(" -inputhandler "); //$NON-NLS-1$ |
458 |
// } |
| 459 |
commandLine.append(REMOTE_INPUT_HANDLER_CLASS); |
459 |
// } else { |
| 460 |
} |
460 |
// if (commandLine.indexOf("-inputhandler") == -1 && setInputHandler) { //$NON-NLS-1$ |
| 461 |
} else { |
461 |
// commandLine.append(" -inputhandler "); //$NON-NLS-1$ |
| 462 |
if (commandLine.indexOf("-inputhandler") == -1 && setInputHandler) { //$NON-NLS-1$ |
462 |
// commandLine.append(INPUT_HANDLER_CLASS); |
| 463 |
commandLine.append(" -inputhandler "); //$NON-NLS-1$ |
463 |
// } |
| 464 |
commandLine.append(INPUT_HANDLER_CLASS); |
464 |
// if (commandLine.indexOf("-logger") == -1) { //$NON-NLS-1$ |
| 465 |
} |
465 |
// commandLine.append(" -logger "); //$NON-NLS-1$ |
| 466 |
if (commandLine.indexOf("-logger") == -1) { //$NON-NLS-1$ |
466 |
// if (fMode.equals(ILaunchManager.DEBUG_MODE)) { |
| 467 |
commandLine.append(" -logger "); //$NON-NLS-1$ |
467 |
// commandLine.append(ANT_DEBUG_LOGGER_CLASS); |
| 468 |
if (fMode.equals(ILaunchManager.DEBUG_MODE)) { |
468 |
// } else if (captureOutput) { |
| 469 |
commandLine.append(ANT_DEBUG_LOGGER_CLASS); |
469 |
// commandLine.append(ANT_LOGGER_CLASS); |
| 470 |
} else if (captureOutput) { |
470 |
// } else { |
| 471 |
commandLine.append(ANT_LOGGER_CLASS); |
471 |
// commandLine.append(NULL_LOGGER_CLASS); |
| 472 |
} else { |
472 |
// } |
| 473 |
commandLine.append(NULL_LOGGER_CLASS); |
473 |
// } |
| 474 |
} |
474 |
// } |
| 475 |
} |
475 |
// |
| 476 |
} |
476 |
// if (separateVM) { |
| 477 |
|
477 |
// appendTaskAndTypes(prefs, commandLine); |
| 478 |
if (separateVM) { |
478 |
// } |
| 479 |
appendTaskAndTypes(prefs, commandLine); |
479 |
// commandLine.append(" -buildfile \""); //$NON-NLS-1$ |
| 480 |
} |
480 |
// commandLine.append(location.toOSString()); |
| 481 |
commandLine.append(" -buildfile \""); //$NON-NLS-1$ |
481 |
// commandLine.append('\"'); |
| 482 |
commandLine.append(location.toOSString()); |
482 |
// |
| 483 |
commandLine.append('\"'); |
483 |
// if (targets != null) { |
| 484 |
|
484 |
// for (int i = 0; i < targets.length; i++) { |
| 485 |
if (targets != null) { |
485 |
// commandLine.append(" \""); //$NON-NLS-1$ |
| 486 |
for (int i = 0; i < targets.length; i++) { |
486 |
// commandLine.append(targets[i]); |
| 487 |
commandLine.append(" \""); //$NON-NLS-1$ |
487 |
// commandLine.append('\"'); |
| 488 |
commandLine.append(targets[i]); |
488 |
// } |
| 489 |
commandLine.append('\"'); |
489 |
// } |
| 490 |
} |
490 |
// return commandLine; |
| 491 |
} |
491 |
// } |
| 492 |
return commandLine; |
492 |
// |
| 493 |
} |
493 |
// private void appendTaskAndTypes(AntCorePreferences prefs, StringBuffer commandLine) { |
| 494 |
|
494 |
// List tasks= prefs.getRemoteTasks(); |
| 495 |
private void appendTaskAndTypes(AntCorePreferences prefs, StringBuffer commandLine) { |
495 |
// Iterator itr= tasks.iterator(); |
| 496 |
List tasks= prefs.getRemoteTasks(); |
496 |
// while (itr.hasNext()) { |
| 497 |
Iterator itr= tasks.iterator(); |
497 |
// Task task = (Task) itr.next(); |
| 498 |
while (itr.hasNext()) { |
498 |
// commandLine.append(" -eclipseTask "); //$NON-NLS-1$ |
| 499 |
Task task = (Task) itr.next(); |
499 |
// String name= ProjectHelper.genComponentName(task.getURI(), task.getTaskName()); |
| 500 |
commandLine.append(" -eclipseTask "); //$NON-NLS-1$ |
500 |
// commandLine.append(name); |
| 501 |
String name= ProjectHelper.genComponentName(task.getURI(), task.getTaskName()); |
501 |
// commandLine.append(','); |
| 502 |
commandLine.append(name); |
502 |
// commandLine.append(task.getClassName()); |
| 503 |
commandLine.append(','); |
503 |
// } |
| 504 |
commandLine.append(task.getClassName()); |
504 |
// |
| 505 |
} |
505 |
// List types= prefs.getRemoteTypes(); |
| 506 |
|
506 |
// itr= types.iterator(); |
| 507 |
List types= prefs.getRemoteTypes(); |
507 |
// while (itr.hasNext()) { |
| 508 |
itr= types.iterator(); |
508 |
// Type type = (Type) itr.next(); |
| 509 |
while (itr.hasNext()) { |
509 |
// commandLine.append(" -eclipseType "); //$NON-NLS-1$ |
| 510 |
Type type = (Type) itr.next(); |
510 |
// String name= ProjectHelper.genComponentName(type.getURI(), type.getTypeName()); |
| 511 |
commandLine.append(" -eclipseType "); //$NON-NLS-1$ |
511 |
// commandLine.append(name); |
| 512 |
String name= ProjectHelper.genComponentName(type.getURI(), type.getTypeName()); |
512 |
// commandLine.append(','); |
| 513 |
commandLine.append(name); |
513 |
// commandLine.append(type.getClassName()); |
| 514 |
commandLine.append(','); |
514 |
// } |
| 515 |
commandLine.append(type.getClassName()); |
515 |
// } |
| 516 |
} |
516 |
// |
| 517 |
} |
517 |
// private void appendProperty(StringBuffer commandLine, String name, String value) { |
| 518 |
|
518 |
// commandLine.append(" \"-D"); //$NON-NLS-1$ |
| 519 |
private void appendProperty(StringBuffer commandLine, String name, String value) { |
519 |
// commandLine.append(name); |
| 520 |
commandLine.append(" \"-D"); //$NON-NLS-1$ |
520 |
// commandLine.append('='); |
| 521 |
commandLine.append(name); |
521 |
// commandLine.append(value); |
| 522 |
commandLine.append('='); |
522 |
// if (value.length() > 0 && value.charAt(value.length() - 1) == File.separatorChar) { |
| 523 |
commandLine.append(value); |
523 |
// commandLine.append(File.separatorChar); |
| 524 |
if (value.length() > 0 && value.charAt(value.length() - 1) == File.separatorChar) { |
524 |
// } |
| 525 |
commandLine.append(File.separatorChar); |
525 |
// commandLine.append("\""); //$NON-NLS-1$ |
| 526 |
} |
526 |
// } |
| 527 |
commandLine.append("\""); //$NON-NLS-1$ |
527 |
// |
| 528 |
} |
528 |
// private void runInSeparateVM(ILaunchConfiguration configuration, ILaunch launch, IProgressMonitor monitor, String idStamp, String antHome, int port, int requestPort, StringBuffer commandLine, boolean captureOutput, boolean setInputHandler) throws CoreException { |
| 529 |
|
529 |
// boolean debug= fMode.equals(ILaunchManager.DEBUG_MODE); |
| 530 |
private void runInSeparateVM(ILaunchConfiguration configuration, ILaunch launch, IProgressMonitor monitor, String idStamp, String antHome, int port, int requestPort, StringBuffer commandLine, boolean captureOutput, boolean setInputHandler) throws CoreException { |
530 |
// if (captureOutput) { |
| 531 |
boolean debug= fMode.equals(ILaunchManager.DEBUG_MODE); |
531 |
// if (debug) { |
| 532 |
if (captureOutput) { |
532 |
// RemoteAntDebugBuildListener listener= new RemoteAntDebugBuildListener(launch); |
| 533 |
if (debug) { |
533 |
// if (requestPort != -1) { |
| 534 |
RemoteAntDebugBuildListener listener= new RemoteAntDebugBuildListener(launch); |
534 |
// listener.startListening(port, requestPort); |
| 535 |
if (requestPort != -1) { |
535 |
// } |
| 536 |
listener.startListening(port, requestPort); |
536 |
// } else if (!fUserSpecifiedLogger) { |
| 537 |
} |
537 |
// RemoteAntBuildListener client= new RemoteAntBuildListener(launch); |
| 538 |
} else if (!fUserSpecifiedLogger) { |
538 |
// if (port != -1) { |
| 539 |
RemoteAntBuildListener client= new RemoteAntBuildListener(launch); |
539 |
// client.startListening(port); |
| 540 |
if (port != -1) { |
540 |
// } |
| 541 |
client.startListening(port); |
541 |
// } |
| 542 |
} |
542 |
// } |
| 543 |
} |
543 |
// |
| 544 |
} |
544 |
// ILaunchConfigurationWorkingCopy copy= configuration.getWorkingCopy(); |
| 545 |
|
545 |
// setDefaultWorkingDirectory(copy); |
| 546 |
ILaunchConfigurationWorkingCopy copy= configuration.getWorkingCopy(); |
546 |
// copy.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS, commandLine.toString()); |
| 547 |
setDefaultWorkingDirectory(copy); |
547 |
// StringBuffer vmArgs= generateVMArguments(copy, setInputHandler, antHome); |
| 548 |
copy.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS, commandLine.toString()); |
548 |
// copy.setAttribute(IJavaLaunchConfigurationConstants.ATTR_VM_ARGUMENTS, vmArgs.toString()); |
| 549 |
StringBuffer vmArgs= generateVMArguments(copy, setInputHandler, antHome); |
549 |
// copy.setAttribute(IDebugUIConstants.ATTR_PRIVATE, true); |
| 550 |
copy.setAttribute(IJavaLaunchConfigurationConstants.ATTR_VM_ARGUMENTS, vmArgs.toString()); |
550 |
// if (copy.getAttribute(IAntLaunchConfigurationConstants.ATTR_DEFAULT_VM_INSTALL, false)) { |
| 551 |
copy.setAttribute(IDebugUIConstants.ATTR_PRIVATE, true); |
551 |
// setDefaultVM(configuration, copy); |
| 552 |
if (copy.getAttribute(IAntLaunchConfigurationConstants.ATTR_DEFAULT_VM_INSTALL, false)) { |
552 |
// } |
| 553 |
setDefaultVM(configuration, copy); |
553 |
// if (debug) { //do not allow launch in foreground bug 83254 |
| 554 |
} |
554 |
// copy.setAttribute(IDebugUIConstants.ATTR_LAUNCH_IN_BACKGROUND, true); |
| 555 |
if (debug) { //do not allow launch in foreground bug 83254 |
555 |
// } |
| 556 |
copy.setAttribute(IDebugUIConstants.ATTR_LAUNCH_IN_BACKGROUND, true); |
556 |
// |
| 557 |
} |
557 |
// //set the ANT_HOME environment variable |
| 558 |
|
558 |
// if (antHome != null) { |
| 559 |
//set the ANT_HOME environment variable |
559 |
// Map vars = copy.getAttribute(ILaunchManager.ATTR_ENVIRONMENT_VARIABLES, new HashMap(1)); |
| 560 |
if (antHome != null) { |
560 |
// vars.put("ANT_HOME", antHome); //$NON-NLS-1$ |
| 561 |
Map vars = copy.getAttribute(ILaunchManager.ATTR_ENVIRONMENT_VARIABLES, new HashMap(1)); |
561 |
// copy.setAttribute(ILaunchManager.ATTR_ENVIRONMENT_VARIABLES, vars); |
| 562 |
vars.put("ANT_HOME", antHome); //$NON-NLS-1$ |
562 |
// } |
| 563 |
copy.setAttribute(ILaunchManager.ATTR_ENVIRONMENT_VARIABLES, vars); |
563 |
// |
| 564 |
} |
564 |
// //copy.setAttribute(IJavaLaunchConfigurationConstants.ATTR_VM_ARGUMENTS, "-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000"); |
| 565 |
|
565 |
// IProgressMonitor subMonitor= new SubProgressMonitor(monitor, 10); |
| 566 |
//copy.setAttribute(IJavaLaunchConfigurationConstants.ATTR_VM_ARGUMENTS, "-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000"); |
566 |
// AntJavaLaunchDelegate delegate= new AntJavaLaunchDelegate(); |
| 567 |
IProgressMonitor subMonitor= new SubProgressMonitor(monitor, 10); |
567 |
// delegate.preLaunchCheck(copy, ILaunchManager.RUN_MODE, subMonitor); |
| 568 |
AntJavaLaunchDelegate delegate= new AntJavaLaunchDelegate(); |
568 |
// delegate.launch(copy, ILaunchManager.RUN_MODE, launch, subMonitor); |
| 569 |
delegate.preLaunchCheck(copy, ILaunchManager.RUN_MODE, subMonitor); |
569 |
// final IProcess[] processes= launch.getProcesses(); |
| 570 |
delegate.launch(copy, ILaunchManager.RUN_MODE, launch, subMonitor); |
570 |
// for (int i = 0; i < processes.length; i++) { |
| 571 |
final IProcess[] processes= launch.getProcesses(); |
571 |
// setProcessAttributes(processes[i], idStamp, null, captureOutput); |
| 572 |
for (int i = 0; i < processes.length; i++) { |
572 |
// } |
| 573 |
setProcessAttributes(processes[i], idStamp, null, captureOutput); |
573 |
// |
| 574 |
} |
574 |
// if (CommonTab.isLaunchInBackground(copy)) { |
| 575 |
|
575 |
// // refresh resources after process finishes |
| 576 |
if (CommonTab.isLaunchInBackground(copy)) { |
576 |
// if (RefreshTab.getRefreshScope(configuration) != null) { |
| 577 |
// refresh resources after process finishes |
577 |
// BackgroundResourceRefresher refresher = new BackgroundResourceRefresher(configuration, processes[0]); |
| 578 |
if (RefreshTab.getRefreshScope(configuration) != null) { |
578 |
// refresher.startBackgroundRefresh(); |
| 579 |
BackgroundResourceRefresher refresher = new BackgroundResourceRefresher(configuration, processes[0]); |
579 |
// } |
| 580 |
refresher.startBackgroundRefresh(); |
580 |
// } else { |
| 581 |
} |
581 |
// final boolean[] terminated= new boolean[1]; |
| 582 |
} else { |
582 |
// terminated[0]= launch.isTerminated(); |
| 583 |
final boolean[] terminated= new boolean[1]; |
583 |
// IDebugEventSetListener listener= new IDebugEventSetListener() { |
| 584 |
terminated[0]= launch.isTerminated(); |
584 |
// public void handleDebugEvents(DebugEvent[] events) { |
| 585 |
IDebugEventSetListener listener= new IDebugEventSetListener() { |
585 |
// for (int i = 0; i < events.length; i++) { |
| 586 |
public void handleDebugEvents(DebugEvent[] events) { |
586 |
// DebugEvent event = events[i]; |
| 587 |
for (int i = 0; i < events.length; i++) { |
587 |
// for (int j= 0, numProcesses= processes.length; j < numProcesses; j++) { |
| 588 |
DebugEvent event = events[i]; |
588 |
// if (event.getSource() == processes[j] && event.getKind() == DebugEvent.TERMINATE) { |
| 589 |
for (int j= 0, numProcesses= processes.length; j < numProcesses; j++) { |
589 |
// terminated[0]= true; |
| 590 |
if (event.getSource() == processes[j] && event.getKind() == DebugEvent.TERMINATE) { |
590 |
// break; |
| 591 |
terminated[0]= true; |
591 |
// } |
| 592 |
break; |
592 |
// } |
| 593 |
} |
593 |
// } |
| 594 |
} |
594 |
// } |
| 595 |
} |
595 |
// }; |
| 596 |
} |
596 |
// DebugPlugin.getDefault().addDebugEventListener(listener); |
| 597 |
}; |
597 |
// monitor.subTask(AntLaunchConfigurationMessages.AntLaunchDelegate_28); |
| 598 |
DebugPlugin.getDefault().addDebugEventListener(listener); |
598 |
// while (!monitor.isCanceled() && !terminated[0]) { |
| 599 |
monitor.subTask(AntLaunchConfigurationMessages.AntLaunchDelegate_28); |
599 |
// try { |
| 600 |
while (!monitor.isCanceled() && !terminated[0]) { |
600 |
// Thread.sleep(50); |
| 601 |
try { |
601 |
// } catch (InterruptedException e) { |
| 602 |
Thread.sleep(50); |
602 |
// } |
| 603 |
} catch (InterruptedException e) { |
603 |
// } |
| 604 |
} |
604 |
// DebugPlugin.getDefault().removeDebugEventListener(listener); |
| 605 |
} |
605 |
// if (!monitor.isCanceled()) { |
| 606 |
DebugPlugin.getDefault().removeDebugEventListener(listener); |
606 |
// // refresh resources |
| 607 |
if (!monitor.isCanceled()) { |
607 |
// RefreshTab.refreshResources(configuration, monitor); |
| 608 |
// refresh resources |
608 |
// } |
| 609 |
RefreshTab.refreshResources(configuration, monitor); |
609 |
// } |
| 610 |
} |
610 |
// } |
| 611 |
} |
611 |
// |
| 612 |
} |
612 |
// private void setDefaultVM(ILaunchConfiguration configuration, ILaunchConfigurationWorkingCopy copy) { |
| 613 |
|
613 |
// try { |
| 614 |
private void setDefaultVM(ILaunchConfiguration configuration, ILaunchConfigurationWorkingCopy copy) { |
614 |
// JavaRuntime.getJavaProject(configuration); |
| 615 |
try { |
615 |
// //remove the vm name, install type and jre container path for the Java launching concept of default VM |
| 616 |
JavaRuntime.getJavaProject(configuration); |
616 |
// copy.setAttribute(IJavaLaunchConfigurationConstants.ATTR_VM_INSTALL_NAME, (String)null); |
| 617 |
//remove the vm name, install type and jre container path for the Java launching concept of default VM |
617 |
// copy.setAttribute(IJavaLaunchConfigurationConstants.ATTR_VM_INSTALL_TYPE, (String)null); |
| 618 |
copy.setAttribute(IJavaLaunchConfigurationConstants.ATTR_VM_INSTALL_NAME, (String)null); |
618 |
// copy.setAttribute(IJavaLaunchConfigurationConstants.ATTR_JRE_CONTAINER_PATH, (String)null); |
| 619 |
copy.setAttribute(IJavaLaunchConfigurationConstants.ATTR_VM_INSTALL_TYPE, (String)null); |
619 |
// } catch (CoreException ce) { |
| 620 |
copy.setAttribute(IJavaLaunchConfigurationConstants.ATTR_JRE_CONTAINER_PATH, (String)null); |
620 |
// //not in a Java project |
| 621 |
} catch (CoreException ce) { |
621 |
// IVMInstall defaultVMInstall= JavaRuntime.getDefaultVMInstall(); |
| 622 |
//not in a Java project |
622 |
// copy.setAttribute(IJavaLaunchConfigurationConstants.ATTR_VM_INSTALL_NAME, defaultVMInstall.getName()); |
| 623 |
IVMInstall defaultVMInstall= JavaRuntime.getDefaultVMInstall(); |
623 |
// copy.setAttribute(IJavaLaunchConfigurationConstants.ATTR_VM_INSTALL_TYPE, defaultVMInstall.getVMInstallType().getId()); |
| 624 |
copy.setAttribute(IJavaLaunchConfigurationConstants.ATTR_VM_INSTALL_NAME, defaultVMInstall.getName()); |
624 |
// } |
| 625 |
copy.setAttribute(IJavaLaunchConfigurationConstants.ATTR_VM_INSTALL_TYPE, defaultVMInstall.getVMInstallType().getId()); |
625 |
// } |
| 626 |
} |
626 |
// |
| 627 |
} |
627 |
// private StringBuffer generateVMArguments(ILaunchConfiguration config, boolean setInputHandler, String antHome) { |
| 628 |
|
628 |
// StringBuffer vmArgs= new StringBuffer(); |
| 629 |
private StringBuffer generateVMArguments(ILaunchConfiguration config, boolean setInputHandler, String antHome) { |
629 |
// try { |
| 630 |
StringBuffer vmArgs= new StringBuffer(); |
630 |
// String configArgs= config.getAttribute(IJavaLaunchConfigurationConstants.ATTR_VM_ARGUMENTS, (String)null); |
| 631 |
try { |
631 |
// if (configArgs != null) { |
| 632 |
String configArgs= config.getAttribute(IJavaLaunchConfigurationConstants.ATTR_VM_ARGUMENTS, (String)null); |
632 |
// vmArgs.append(configArgs); |
| 633 |
if (configArgs != null) { |
633 |
// vmArgs.append(' '); |
| 634 |
vmArgs.append(configArgs); |
634 |
// } |
| 635 |
vmArgs.append(' '); |
635 |
// } catch (CoreException e) { |
| 636 |
} |
636 |
// } |
| 637 |
} catch (CoreException e) { |
637 |
// |
| 638 |
} |
638 |
// if (antHome != null) { |
| 639 |
|
639 |
// vmArgs.append("-Dant.home=\""); //$NON-NLS-1$ |
| 640 |
if (antHome != null) { |
640 |
// vmArgs.append(antHome); |
| 641 |
vmArgs.append("-Dant.home=\""); //$NON-NLS-1$ |
641 |
// vmArgs.append("\" "); //$NON-NLS-1$ |
| 642 |
vmArgs.append(antHome); |
642 |
// |
| 643 |
vmArgs.append("\" "); //$NON-NLS-1$ |
643 |
// File antLibDir= new File(antHome, "lib"); //$NON-NLS-1$ |
| 644 |
|
644 |
// vmArgs.append("-Dant.library.dir=\""); //$NON-NLS-1$ |
| 645 |
File antLibDir= new File(antHome, "lib"); //$NON-NLS-1$ |
645 |
// vmArgs.append(antLibDir.getAbsolutePath()); |
| 646 |
vmArgs.append("-Dant.library.dir=\""); //$NON-NLS-1$ |
646 |
// vmArgs.append('\"'); |
| 647 |
vmArgs.append(antLibDir.getAbsolutePath()); |
647 |
// } |
| 648 |
vmArgs.append('\"'); |
648 |
// if (setInputHandler) { |
| 649 |
} |
649 |
// String swtLocation= getSWTLibraryLocation(); |
| 650 |
if (setInputHandler) { |
650 |
// if (swtLocation != null) { |
| 651 |
String swtLocation= getSWTLibraryLocation(); |
651 |
// vmArgs.append(" -Djava.library.path=\""); //$NON-NLS-1$ |
| 652 |
if (swtLocation != null) { |
652 |
// String javaLibPath= System.getProperty("java.library.path"); //$NON-NLS-1$ |
| 653 |
vmArgs.append(" -Djava.library.path=\""); //$NON-NLS-1$ |
653 |
// javaLibPath= stripUnescapedQuotes(javaLibPath); |
| 654 |
String javaLibPath= System.getProperty("java.library.path"); //$NON-NLS-1$ |
654 |
// if (javaLibPath != null) { |
| 655 |
javaLibPath= stripUnescapedQuotes(javaLibPath); |
655 |
// vmArgs.append(javaLibPath); |
| 656 |
if (javaLibPath != null) { |
656 |
// if (vmArgs.charAt(vmArgs.length() - 1) != File.pathSeparatorChar) { |
| 657 |
vmArgs.append(javaLibPath); |
657 |
// vmArgs.append(File.pathSeparatorChar); |
| 658 |
if (vmArgs.charAt(vmArgs.length() - 1) != File.pathSeparatorChar) { |
658 |
// } |
| 659 |
vmArgs.append(File.pathSeparatorChar); |
659 |
// } |
| 660 |
} |
660 |
// vmArgs.append(swtLocation); |
| 661 |
} |
661 |
// vmArgs.append('"'); |
| 662 |
vmArgs.append(swtLocation); |
662 |
// } |
| 663 |
vmArgs.append('"'); |
663 |
// } |
| 664 |
} |
664 |
// return vmArgs; |
| 665 |
} |
665 |
// } |
| 666 |
return vmArgs; |
666 |
// |
| 667 |
} |
667 |
// private String stripUnescapedQuotes(String javaLibPath) { |
| 668 |
|
668 |
// StringBuffer buf = new StringBuffer(javaLibPath.length()); |
| 669 |
private String stripUnescapedQuotes(String javaLibPath) { |
669 |
// for (int i = 0; i < javaLibPath.length(); i++) { |
| 670 |
StringBuffer buf = new StringBuffer(javaLibPath.length()); |
670 |
// char c = javaLibPath.charAt(i); |
| 671 |
for (int i = 0; i < javaLibPath.length(); i++) { |
671 |
// switch (c) { |
| 672 |
char c = javaLibPath.charAt(i); |
672 |
// case '"': |
| 673 |
switch (c) { |
673 |
// if (i != 0 && javaLibPath.charAt(i-1) == '\\') { |
| 674 |
case '"': |
674 |
// buf.append(c); |
| 675 |
if (i != 0 && javaLibPath.charAt(i-1) == '\\') { |
675 |
// } |
| 676 |
buf.append(c); |
676 |
// break; |
| 677 |
} |
677 |
// default: |
| 678 |
break; |
678 |
// buf.append(c); |
| 679 |
default: |
679 |
// break; |
| 680 |
buf.append(c); |
680 |
// } |
| 681 |
break; |
681 |
// } |
| 682 |
} |
682 |
// return buf.toString(); |
| 683 |
} |
683 |
// } |
| 684 |
return buf.toString(); |
684 |
// |
| 685 |
} |
685 |
// /* (non-Javadoc) |
| 686 |
|
686 |
// * @see org.eclipse.debug.core.model.LaunchConfigurationDelegate#getBuildOrder(org.eclipse.debug.core.ILaunchConfiguration, java.lang.String) |
| 687 |
/* (non-Javadoc) |
687 |
// */ |
| 688 |
* @see org.eclipse.debug.core.model.LaunchConfigurationDelegate#getBuildOrder(org.eclipse.debug.core.ILaunchConfiguration, java.lang.String) |
688 |
// protected IProject[] getBuildOrder(ILaunchConfiguration configuration, String mode) throws CoreException { |
| 689 |
*/ |
689 |
// IProject[] projects = ExternalToolsBuildTab.getBuildProjects(configuration, ATTR_BUILD_SCOPE); |
| 690 |
protected IProject[] getBuildOrder(ILaunchConfiguration configuration, String mode) throws CoreException { |
690 |
// if (projects == null) { |
| 691 |
IProject[] projects = ExternalToolsBuildTab.getBuildProjects(configuration, ATTR_BUILD_SCOPE); |
691 |
// return NO_PROJECTS; |
| 692 |
if (projects == null) { |
692 |
// } |
| 693 |
return NO_PROJECTS; |
693 |
// boolean isRef = ExternalToolsBuildTab.isIncludeReferencedProjects(configuration, ATTR_INCLUDE_REFERENCED_PROJECTS); |
| 694 |
} |
694 |
// if (isRef) { |
| 695 |
boolean isRef = ExternalToolsBuildTab.isIncludeReferencedProjects(configuration, ATTR_INCLUDE_REFERENCED_PROJECTS); |
695 |
// return computeReferencedBuildOrder(projects); |
| 696 |
if (isRef) { |
696 |
// } |
| 697 |
return computeReferencedBuildOrder(projects); |
697 |
// return computeBuildOrder(projects); |
| 698 |
} |
698 |
// } |
| 699 |
return computeBuildOrder(projects); |
699 |
// |
| 700 |
} |
700 |
// private String getSWTLibraryLocation() { |
| 701 |
|
701 |
// if (fgSWTLibraryLocation == null) { |
| 702 |
private String getSWTLibraryLocation() { |
702 |
// Bundle bundle= Platform.getBundle("org.eclipse.swt"); //$NON-NLS-1$ |
| 703 |
if (fgSWTLibraryLocation == null) { |
703 |
// BundleDescription description= Platform.getPlatformAdmin().getState(false).getBundle(bundle.getBundleId()); |
| 704 |
Bundle bundle= Platform.getBundle("org.eclipse.swt"); //$NON-NLS-1$ |
704 |
// BundleDescription[] fragments= description.getFragments(); |
| 705 |
BundleDescription description= Platform.getPlatformAdmin().getState(false).getBundle(bundle.getBundleId()); |
705 |
// if (fragments == null || fragments.length == 0) { |
| 706 |
BundleDescription[] fragments= description.getFragments(); |
706 |
// return null; |
| 707 |
if (fragments == null || fragments.length == 0) { |
707 |
// } |
| 708 |
return null; |
708 |
// Bundle fragBundle= Platform.getBundle(fragments[0].getSymbolicName()); |
| 709 |
} |
709 |
// try { |
| 710 |
Bundle fragBundle= Platform.getBundle(fragments[0].getSymbolicName()); |
710 |
// URL url= FileLocator.toFileURL(fragBundle.getEntry("/")); //$NON-NLS-1$ |
| 711 |
try { |
711 |
// IPath path= new Path(url.getPath()); |
| 712 |
URL url= FileLocator.toFileURL(fragBundle.getEntry("/")); //$NON-NLS-1$ |
712 |
// path= path.removeTrailingSeparator(); |
| 713 |
IPath path= new Path(url.getPath()); |
713 |
// fgSWTLibraryLocation= path.toOSString(); |
| 714 |
path= path.removeTrailingSeparator(); |
714 |
// } catch (IOException e) { |
| 715 |
fgSWTLibraryLocation= path.toOSString(); |
715 |
// } |
| 716 |
} catch (IOException e) { |
716 |
// } |
| 717 |
} |
717 |
// return fgSWTLibraryLocation; |
| 718 |
} |
718 |
// } |
| 719 |
return fgSWTLibraryLocation; |
719 |
// |
| 720 |
} |
720 |
// /* (non-Javadoc) |
| 721 |
|
721 |
// * @see org.eclipse.debug.core.model.LaunchConfigurationDelegate#getBreakpoints(org.eclipse.debug.core.ILaunchConfiguration) |
| 722 |
/* (non-Javadoc) |
722 |
// */ |
| 723 |
* @see org.eclipse.debug.core.model.LaunchConfigurationDelegate#getBreakpoints(org.eclipse.debug.core.ILaunchConfiguration) |
723 |
// protected IBreakpoint[] getBreakpoints(ILaunchConfiguration configuration) { |
| 724 |
*/ |
724 |
// IBreakpointManager breakpointManager = DebugPlugin.getDefault().getBreakpointManager(); |
| 725 |
protected IBreakpoint[] getBreakpoints(ILaunchConfiguration configuration) { |
725 |
// if (!breakpointManager.isEnabled()) { |
| 726 |
IBreakpointManager breakpointManager = DebugPlugin.getDefault().getBreakpointManager(); |
726 |
// // no need to check breakpoints individually. |
| 727 |
if (!breakpointManager.isEnabled()) { |
727 |
// return null; |
| 728 |
// no need to check breakpoints individually. |
728 |
// } |
| 729 |
return null; |
729 |
// return breakpointManager.getBreakpoints(IAntDebugConstants.ID_ANT_DEBUG_MODEL); |
| 730 |
} |
730 |
// } |
| 731 |
return breakpointManager.getBreakpoints(IAntDebugConstants.ID_ANT_DEBUG_MODEL); |
731 |
// |
| 732 |
} |
732 |
// /* (non-Javadoc) |
| 733 |
|
733 |
// * @see org.eclipse.debug.core.model.LaunchConfigurationDelegate#saveBeforeLaunch(org.eclipse.debug.core.ILaunchConfiguration, java.lang.String, org.eclipse.core.runtime.IProgressMonitor) |
| 734 |
/* (non-Javadoc) |
734 |
// */ |
| 735 |
* @see org.eclipse.debug.core.model.LaunchConfigurationDelegate#saveBeforeLaunch(org.eclipse.debug.core.ILaunchConfiguration, java.lang.String, org.eclipse.core.runtime.IProgressMonitor) |
735 |
// protected boolean saveBeforeLaunch(ILaunchConfiguration configuration, String mode, IProgressMonitor monitor) throws CoreException { |
| 736 |
*/ |
736 |
// if (IExternalToolConstants.ID_EXTERNAL_TOOLS_BUILDER_LAUNCH_CATEGORY.equals( |
| 737 |
protected boolean saveBeforeLaunch(ILaunchConfiguration configuration, String mode, IProgressMonitor monitor) throws CoreException { |
737 |
// configuration.getType().getCategory())) { |
| 738 |
if (IExternalToolConstants.ID_EXTERNAL_TOOLS_BUILDER_LAUNCH_CATEGORY.equals( |
738 |
// // don't prompt for builders |
| 739 |
configuration.getType().getCategory())) { |
739 |
// return true; |
| 740 |
// don't prompt for builders |
740 |
// } |
| 741 |
return true; |
741 |
// return super.saveBeforeLaunch(configuration, mode, monitor); |
| 742 |
} |
742 |
// } |
| 743 |
return super.saveBeforeLaunch(configuration, mode, monitor); |
743 |
// |
| 744 |
} |
744 |
// /** |
| 745 |
|
745 |
// * Sets the default working directory to be the parent folder of the buildfile if |
| 746 |
/** |
746 |
// * the user has not explicitly set the working directory. |
| 747 |
* Sets the default working directory to be the parent folder of the buildfile if |
747 |
// */ |
| 748 |
* the user has not explicitly set the working directory. |
748 |
// private void setDefaultWorkingDirectory(ILaunchConfigurationWorkingCopy copy) { |
| 749 |
*/ |
749 |
// try { |
| 750 |
private void setDefaultWorkingDirectory(ILaunchConfigurationWorkingCopy copy) { |
750 |
// String wd = copy.getAttribute(IJavaLaunchConfigurationConstants.ATTR_WORKING_DIRECTORY, (String)null); |
| 751 |
try { |
751 |
// if (wd == null) { |
| 752 |
String wd = copy.getAttribute(IJavaLaunchConfigurationConstants.ATTR_WORKING_DIRECTORY, (String)null); |
752 |
// wd= ExternalToolsUtil.getLocation(copy).removeLastSegments(1).toOSString(); |
| 753 |
if (wd == null) { |
753 |
// copy.setAttribute(IJavaLaunchConfigurationConstants.ATTR_WORKING_DIRECTORY, wd); |
| 754 |
wd= ExternalToolsUtil.getLocation(copy).removeLastSegments(1).toOSString(); |
754 |
// } |
| 755 |
copy.setAttribute(IJavaLaunchConfigurationConstants.ATTR_WORKING_DIRECTORY, wd); |
755 |
// } catch (CoreException e) { |
| 756 |
} |
756 |
// AntUIPlugin.log(e.getStatus()); |
| 757 |
} catch (CoreException e) { |
757 |
// } |
| 758 |
AntUIPlugin.log(e.getStatus()); |
758 |
// } |
| 759 |
} |
759 |
//} |
| 760 |
} |
|
|
| 761 |
} |