Lines 19-24
Link Here
|
19 |
import java.util.List; |
19 |
import java.util.List; |
20 |
import java.util.Map; |
20 |
import java.util.Map; |
21 |
|
21 |
|
|
|
22 |
import org.apache.tools.ant.taskdefs.Jar; |
23 |
import org.apache.tools.ant.taskdefs.Manifest; |
24 |
import org.apache.tools.ant.taskdefs.Manifest.Attribute; |
25 |
import org.apache.tools.ant.taskdefs.ManifestException; |
22 |
import org.eclipse.core.runtime.CoreException; |
26 |
import org.eclipse.core.runtime.CoreException; |
23 |
import org.eclipse.core.runtime.IPath; |
27 |
import org.eclipse.core.runtime.IPath; |
24 |
import org.eclipse.core.runtime.IProgressMonitor; |
28 |
import org.eclipse.core.runtime.IProgressMonitor; |
Lines 204-211
Link Here
|
204 |
addBootClassPathArguments(arguments, config); |
208 |
addBootClassPathArguments(arguments, config); |
205 |
|
209 |
|
206 |
String[] cp= config.getClassPath(); |
210 |
String[] cp= config.getClassPath(); |
|
|
211 |
int classpathArgIndex = -1; |
207 |
if (cp.length > 0) { |
212 |
if (cp.length > 0) { |
208 |
arguments.add("-classpath"); //$NON-NLS-1$ |
213 |
arguments.add("-classpath"); //$NON-NLS-1$ |
|
|
214 |
classpathArgIndex = arguments.size(); |
209 |
arguments.add(convertClassPath(cp)); |
215 |
arguments.add(convertClassPath(cp)); |
210 |
} |
216 |
} |
211 |
|
217 |
|
Lines 213-218
Link Here
|
213 |
|
219 |
|
214 |
arguments.add(config.getClassToLaunch()); |
220 |
arguments.add(config.getClassToLaunch()); |
215 |
addArguments(config.getProgramArguments(), arguments); |
221 |
addArguments(config.getProgramArguments(), arguments); |
|
|
222 |
|
223 |
if (classpathArgIndex > -1 |
224 |
&& ((String)arguments.get(classpathArgIndex)).length() > 256 // can be shortened |
225 |
&& File.separatorChar == '\\' // is Windows |
226 |
) |
227 |
{ |
228 |
int cmdLen = 0; |
229 |
for (int i = 0, sz = arguments.size(); i < sz; i++) { |
230 |
cmdLen += ((String)arguments.get(i)).length() + 1; |
231 |
} |
232 |
if (cmdLen > 30000) { |
233 |
Jar jar = new Jar(); |
234 |
Manifest mf = new Manifest(); |
235 |
List shortCp = new ArrayList(); |
236 |
int jarCount = 0; |
237 |
StringBuffer sb = new StringBuffer(cmdLen); |
238 |
for (int i = 0; i < cp.length; i++) { |
239 |
String cpEntry = cp[i]; |
240 |
File f; |
241 |
if (cpEntry.toLowerCase().endsWith(".jar") && (f = new File(cpEntry)).isAbsolute()) { |
242 |
sb.append(f.toURI().toString()); |
243 |
sb.append(' '); |
244 |
jarCount++; |
245 |
} else { |
246 |
shortCp.add(cpEntry); |
247 |
} |
248 |
} |
249 |
if (jarCount > 0) { |
250 |
Attribute attr = new Attribute(Manifest.ATTRIBUTE_CLASSPATH, sb.toString()); |
251 |
try { |
252 |
mf.addConfiguredAttribute(attr); |
253 |
jar.addConfiguredManifest(mf); |
254 |
String jarPath = File.createTempFile("classpath", ".jar").getAbsolutePath(); |
255 |
jar.setDestFile(new File(jarPath)); |
256 |
jar.execute(); |
257 |
shortCp.add(jarPath); |
258 |
String[] shortCpA = new String[shortCp.size()]; |
259 |
shortCp.toArray(shortCpA); |
260 |
arguments.set(classpathArgIndex, convertClassPath(shortCpA)); |
261 |
} catch(Exception e) { |
262 |
} |
263 |
} |
264 |
} |
265 |
} |
216 |
String[] cmdLine= new String[arguments.size()]; |
266 |
String[] cmdLine= new String[arguments.size()]; |
217 |
arguments.toArray(cmdLine); |
267 |
arguments.toArray(cmdLine); |
218 |
|
268 |
|