Lines 294-299
Link Here
|
294 |
processArgs(args); |
294 |
processArgs(args); |
295 |
} |
295 |
} |
296 |
|
296 |
|
|
|
297 |
private static String optArg(String[] args, int i) { |
298 |
if (i >= args.length || args[i].equals("--")) { |
299 |
throw new ArrayIndexOutOfBoundsException(); |
300 |
} |
301 |
return args[i]; |
302 |
} |
303 |
|
297 |
/** |
304 |
/** |
298 |
* Process command line arguments. |
305 |
* Process command line arguments. |
299 |
* When ant is started from Launcher, the -lib argument does not get |
306 |
* When ant is started from Launcher, the -lib argument does not get |
Lines 306-318
Link Here
|
306 |
private void processArgs(String[] args) { |
313 |
private void processArgs(String[] args) { |
307 |
String searchForThis = null; |
314 |
String searchForThis = null; |
308 |
PrintStream logTo = null; |
315 |
PrintStream logTo = null; |
|
|
316 |
boolean noMoreArgs = false; |
309 |
|
317 |
|
310 |
// cycle through given args |
318 |
// cycle through given args |
311 |
|
319 |
|
312 |
for (int i = 0; i < args.length; i++) { |
320 |
for (int i = 0; i < args.length; i++) { |
313 |
String arg = args[i]; |
321 |
String arg = args[i]; |
314 |
|
322 |
|
315 |
if (arg.equals("-help") || arg.equals("-h")) { |
323 |
if (noMoreArgs) { |
|
|
324 |
targets.addElement(arg); |
325 |
} else if (arg.equals("--")) { |
326 |
noMoreArgs = true; |
327 |
} else if (arg.equals("-help") || arg.equals("-h")) { |
316 |
printUsage(); |
328 |
printUsage(); |
317 |
return; |
329 |
return; |
318 |
} else if (arg.equals("-version")) { |
330 |
} else if (arg.equals("-version")) { |
Lines 333-339
Link Here
|
333 |
allowInput = false; |
345 |
allowInput = false; |
334 |
} else if (arg.equals("-logfile") || arg.equals("-l")) { |
346 |
} else if (arg.equals("-logfile") || arg.equals("-l")) { |
335 |
try { |
347 |
try { |
336 |
File logFile = new File(args[i + 1]); |
348 |
File logFile = new File(optArg(args, i + 1)); |
337 |
i++; |
349 |
i++; |
338 |
logTo = new PrintStream(new FileOutputStream(logFile)); |
350 |
logTo = new PrintStream(new FileOutputStream(logFile)); |
339 |
isLogFileUsed = true; |
351 |
isLogFileUsed = true; |
Lines 344-356
Link Here
|
344 |
throw new BuildException(msg); |
356 |
throw new BuildException(msg); |
345 |
} catch (ArrayIndexOutOfBoundsException aioobe) { |
357 |
} catch (ArrayIndexOutOfBoundsException aioobe) { |
346 |
String msg = "You must specify a log file when " |
358 |
String msg = "You must specify a log file when " |
347 |
+ "using the -log argument"; |
359 |
+ "using the -logfile argument"; |
348 |
throw new BuildException(msg); |
360 |
throw new BuildException(msg); |
349 |
} |
361 |
} |
350 |
} else if (arg.equals("-buildfile") || arg.equals("-file") |
362 |
} else if (arg.equals("-buildfile") || arg.equals("-file") |
351 |
|| arg.equals("-f")) { |
363 |
|| arg.equals("-f")) { |
352 |
try { |
364 |
try { |
353 |
buildFile = new File(args[i + 1].replace('/', File.separatorChar)); |
365 |
buildFile = new File( |
|
|
366 |
optArg(args, i + 1).replace('/', File.separatorChar)); |
354 |
i++; |
367 |
i++; |
355 |
} catch (ArrayIndexOutOfBoundsException aioobe) { |
368 |
} catch (ArrayIndexOutOfBoundsException aioobe) { |
356 |
String msg = "You must specify a buildfile when " |
369 |
String msg = "You must specify a buildfile when " |
Lines 359-365
Link Here
|
359 |
} |
372 |
} |
360 |
} else if (arg.equals("-listener")) { |
373 |
} else if (arg.equals("-listener")) { |
361 |
try { |
374 |
try { |
362 |
listeners.addElement(args[i + 1]); |
375 |
listeners.addElement(optArg(args, i + 1)); |
363 |
i++; |
376 |
i++; |
364 |
} catch (ArrayIndexOutOfBoundsException aioobe) { |
377 |
} catch (ArrayIndexOutOfBoundsException aioobe) { |
365 |
String msg = "You must specify a classname when " |
378 |
String msg = "You must specify a classname when " |
Lines 385-391
Link Here
|
385 |
if (posEq > 0) { |
398 |
if (posEq > 0) { |
386 |
value = name.substring(posEq + 1); |
399 |
value = name.substring(posEq + 1); |
387 |
name = name.substring(0, posEq); |
400 |
name = name.substring(0, posEq); |
388 |
} else if (i < args.length - 1) { |
401 |
} else if (i < args.length - 1 && !args[i + 1].equals("--")) { |
389 |
value = args[++i]; |
402 |
value = args[++i]; |
390 |
} else { |
403 |
} else { |
391 |
throw new BuildException("Missing value for property " |
404 |
throw new BuildException("Missing value for property " |
Lines 399-405
Link Here
|
399 |
+ " be specified."); |
412 |
+ " be specified."); |
400 |
} |
413 |
} |
401 |
try { |
414 |
try { |
402 |
loggerClassname = args[++i]; |
415 |
loggerClassname = optArg(args, ++i); |
403 |
} catch (ArrayIndexOutOfBoundsException aioobe) { |
416 |
} catch (ArrayIndexOutOfBoundsException aioobe) { |
404 |
throw new BuildException("You must specify a classname when" |
417 |
throw new BuildException("You must specify a classname when" |
405 |
+ " using the -logger argument"); |
418 |
+ " using the -logger argument"); |
Lines 410-416
Link Here
|
410 |
+ "be specified."); |
423 |
+ "be specified."); |
411 |
} |
424 |
} |
412 |
try { |
425 |
try { |
413 |
inputHandlerClassname = args[++i]; |
426 |
inputHandlerClassname = optArg(args, ++i); |
414 |
} catch (ArrayIndexOutOfBoundsException aioobe) { |
427 |
} catch (ArrayIndexOutOfBoundsException aioobe) { |
415 |
throw new BuildException("You must specify a classname when" |
428 |
throw new BuildException("You must specify a classname when" |
416 |
+ " using the -inputhandler" |
429 |
+ " using the -inputhandler" |
Lines 423-447
Link Here
|
423 |
projectHelp = true; |
436 |
projectHelp = true; |
424 |
} else if (arg.equals("-find") || arg.equals("-s")) { |
437 |
} else if (arg.equals("-find") || arg.equals("-s")) { |
425 |
// eat up next arg if present, default to build.xml |
438 |
// eat up next arg if present, default to build.xml |
426 |
if (i < args.length - 1) { |
439 |
if (i < args.length - 1 && !args[i+1].equals("--")) { |
427 |
searchForThis = args[++i]; |
440 |
searchForThis = args[++i]; |
428 |
} else { |
441 |
} else { |
429 |
searchForThis = DEFAULT_BUILD_FILENAME; |
442 |
searchForThis = DEFAULT_BUILD_FILENAME; |
430 |
} |
443 |
} |
431 |
} else if (arg.startsWith("-propertyfile")) { |
444 |
} else if (arg.startsWith("-propertyfile")) { |
432 |
try { |
445 |
String msg = "You must specify a property filename when " |
433 |
propertyFiles.addElement(args[i + 1]); |
446 |
+ "using the -propertyfile argument"; |
434 |
i++; |
447 |
if (i >= args.length - 1 || args[i+1].equals("--")) { |
435 |
} catch (ArrayIndexOutOfBoundsException aioobe) { |
|
|
436 |
String msg = "You must specify a property filename when " |
437 |
+ "using the -propertyfile argument"; |
438 |
throw new BuildException(msg); |
448 |
throw new BuildException(msg); |
439 |
} |
449 |
} |
|
|
450 |
propertyFiles.addElement(args[i + 1]); |
451 |
i++; |
440 |
} else if (arg.equals("-k") || arg.equals("-keep-going")) { |
452 |
} else if (arg.equals("-k") || arg.equals("-keep-going")) { |
441 |
keepGoingMode = true; |
453 |
keepGoingMode = true; |
442 |
} else if (arg.equals("-nice")) { |
454 |
} else if (arg.equals("-nice")) { |
443 |
try { |
455 |
try { |
444 |
threadPriority=Integer.decode(args[i + 1]); |
456 |
threadPriority=Integer.decode(optArg(args, i + 1)); |
445 |
} catch (ArrayIndexOutOfBoundsException aioobe) { |
457 |
} catch (ArrayIndexOutOfBoundsException aioobe) { |
446 |
throw new BuildException( |
458 |
throw new BuildException( |
447 |
"You must supply a niceness value (1-10)"+ |
459 |
"You must supply a niceness value (1-10)"+ |
Lines 864-869
Link Here
|
864 |
msg.append(" -s <file> the filesystem and use it" + lSep); |
876 |
msg.append(" -s <file> the filesystem and use it" + lSep); |
865 |
msg.append(" -nice number A niceness value for the main thread:" + lSep + |
877 |
msg.append(" -nice number A niceness value for the main thread:" + lSep + |
866 |
" 1 (lowest) to 10 (highest); 5 is the default" + lSep); |
878 |
" 1 (lowest) to 10 (highest); 5 is the default" + lSep); |
|
|
879 |
msg.append(" -- signify end of options" + lSep); |
867 |
System.out.println(msg.toString()); |
880 |
System.out.println(msg.toString()); |
868 |
} |
881 |
} |
869 |
|
882 |
|
Lines 1053-1056
Link Here
|
1053 |
} |
1066 |
} |
1054 |
project.log(msg.toString()); |
1067 |
project.log(msg.toString()); |
1055 |
} |
1068 |
} |
1056 |
} |
1069 |
} |