Lines 114-119
Link Here
|
114 |
import org.netbeans.modules.java.api.common.util.CommonProjectUtils; |
114 |
import org.netbeans.modules.java.api.common.util.CommonProjectUtils; |
115 |
import org.netbeans.spi.java.classpath.ClassPathProvider; |
115 |
import org.netbeans.spi.java.classpath.ClassPathProvider; |
116 |
import org.netbeans.spi.java.classpath.support.ClassPathSupport; |
116 |
import org.netbeans.spi.java.classpath.support.ClassPathSupport; |
|
|
117 |
import org.netbeans.spi.project.ActionProgress; |
117 |
import org.netbeans.spi.project.ActionProvider; |
118 |
import org.netbeans.spi.project.ActionProvider; |
118 |
import org.netbeans.spi.project.ProjectConfiguration; |
119 |
import org.netbeans.spi.project.ProjectConfiguration; |
119 |
import org.netbeans.spi.project.SingleMethod; |
120 |
import org.netbeans.spi.project.SingleMethod; |
Lines 406-411
Link Here
|
406 |
final boolean isCompileOnSaveEnabled = isCompileOnSaveEnabled(); |
407 |
final boolean isCompileOnSaveEnabled = isCompileOnSaveEnabled(); |
407 |
final AtomicReference<Thread> caller = new AtomicReference<Thread>(Thread.currentThread()); |
408 |
final AtomicReference<Thread> caller = new AtomicReference<Thread>(Thread.currentThread()); |
408 |
final AtomicBoolean called = new AtomicBoolean(false); |
409 |
final AtomicBoolean called = new AtomicBoolean(false); |
|
|
410 |
final ActionProgress listener = ActionProgress.start(context); |
409 |
|
411 |
|
410 |
class Action implements Runnable { |
412 |
class Action implements Runnable { |
411 |
|
413 |
|
Lines 418-423
Link Here
|
418 |
* the default values (possibly incorrect) are used. |
420 |
* the default values (possibly incorrect) are used. |
419 |
*/ |
421 |
*/ |
420 |
private boolean doJavaChecks = true; |
422 |
private boolean doJavaChecks = true; |
|
|
423 |
ExecutorTask task; |
421 |
|
424 |
|
422 |
@Override |
425 |
@Override |
423 |
public void run () { |
426 |
public void run () { |
Lines 425-430
Link Here
|
425 |
return; |
428 |
return; |
426 |
} |
429 |
} |
427 |
called.set(true); |
430 |
called.set(true); |
|
|
431 |
try { |
432 |
doRun(); |
433 |
} finally { |
434 |
if (task != null) { |
435 |
task.addTaskListener(new TaskListener() { |
436 |
@Override public void taskFinished(Task _) { |
437 |
listener.finished(task.result() == 0); |
438 |
} |
439 |
}); |
440 |
} else { |
441 |
listener.finished(false); |
442 |
} |
443 |
} |
444 |
} |
445 |
|
446 |
void doRun() { |
428 |
Properties p = new Properties(); |
447 |
Properties p = new Properties(); |
429 |
String[] targetNames; |
448 |
String[] targetNames; |
430 |
|
449 |
|
Lines 465-470
Link Here
|
465 |
execProperties.put("applet.url", url); |
484 |
execProperties.put("applet.url", url); |
466 |
execProperties.put(JavaRunner.PROP_EXECUTE_FILE, file); |
485 |
execProperties.put(JavaRunner.PROP_EXECUTE_FILE, file); |
467 |
prepareSystemProperties(execProperties, false); |
486 |
prepareSystemProperties(execProperties, false); |
|
|
487 |
task = |
468 |
JavaRunner.execute(targetNames[0], execProperties); |
488 |
JavaRunner.execute(targetNames[0], execProperties); |
469 |
} |
489 |
} |
470 |
} catch (IOException ex) { |
490 |
} catch (IOException ex) { |
Lines 474-480
Link Here
|
474 |
} |
494 |
} |
475 |
if (!isServerExecution() && (COMMAND_RUN.equals(command) || COMMAND_DEBUG.equals(command) || COMMAND_DEBUG_STEP_INTO.equals(command))) { |
495 |
if (!isServerExecution() && (COMMAND_RUN.equals(command) || COMMAND_DEBUG.equals(command) || COMMAND_DEBUG_STEP_INTO.equals(command))) { |
476 |
prepareSystemProperties(execProperties, false); |
496 |
prepareSystemProperties(execProperties, false); |
477 |
bypassAntBuildScript(command, context, execProperties); |
497 |
AtomicReference<ExecutorTask> _task = new AtomicReference<ExecutorTask>(); |
|
|
498 |
bypassAntBuildScript(command, context, execProperties, _task); |
499 |
task = _task.get(); |
478 |
return ; |
500 |
return ; |
479 |
} |
501 |
} |
480 |
// for example RUN_SINGLE Java file with Servlet must be run on server and not locally |
502 |
// for example RUN_SINGLE Java file with Servlet must be run on server and not locally |
Lines 487-493
Link Here
|
487 |
} else { |
509 |
} else { |
488 |
execProperties.put(JavaRunner.PROP_CLASSNAME, p.getProperty("debug.class")); |
510 |
execProperties.put(JavaRunner.PROP_CLASSNAME, p.getProperty("debug.class")); |
489 |
} |
511 |
} |
490 |
bypassAntBuildScript(command, context, execProperties); |
512 |
AtomicReference<ExecutorTask> _task = new AtomicReference<ExecutorTask>(); |
|
|
513 |
bypassAntBuildScript(command, context, execProperties, _task); |
514 |
task = _task.get(); |
491 |
return; |
515 |
return; |
492 |
} |
516 |
} |
493 |
if (COMMAND_TEST_SINGLE.equals(command) || COMMAND_DEBUG_TEST_SINGLE.equals(command)) { |
517 |
if (COMMAND_TEST_SINGLE.equals(command) || COMMAND_DEBUG_TEST_SINGLE.equals(command)) { |
Lines 497-502
Link Here
|
497 |
execProperties.put(JavaRunner.PROP_EXECUTE_FILE, files[0]); |
521 |
execProperties.put(JavaRunner.PROP_EXECUTE_FILE, files[0]); |
498 |
execProperties.put("tmp.dir", updateHelper.getAntProjectHelper().resolvePath(evaluator.getProperty(ProjectProperties.BUILD_DIR))); //NOI18N |
522 |
execProperties.put("tmp.dir", updateHelper.getAntProjectHelper().resolvePath(evaluator.getProperty(ProjectProperties.BUILD_DIR))); //NOI18N |
499 |
updateJavaRunnerClasspath(command, execProperties); |
523 |
updateJavaRunnerClasspath(command, execProperties); |
|
|
524 |
task = |
500 |
JavaRunner.execute(COMMAND_TEST_SINGLE.equals(command) ? JavaRunner.QUICK_TEST : JavaRunner.QUICK_TEST_DEBUG, execProperties); |
525 |
JavaRunner.execute(COMMAND_TEST_SINGLE.equals(command) ? JavaRunner.QUICK_TEST : JavaRunner.QUICK_TEST_DEBUG, execProperties); |
501 |
} catch (IOException ex) { |
526 |
} catch (IOException ex) { |
502 |
Exceptions.printStackTrace(ex); |
527 |
Exceptions.printStackTrace(ex); |
Lines 510-515
Link Here
|
510 |
execProperties.put(JavaRunner.PROP_EXECUTE_FILE, methodSpec.getFile()); |
535 |
execProperties.put(JavaRunner.PROP_EXECUTE_FILE, methodSpec.getFile()); |
511 |
execProperties.put("tmp.dir",updateHelper.getAntProjectHelper().resolvePath(evaluator.getProperty(ProjectProperties.BUILD_DIR))); //NOI18N |
536 |
execProperties.put("tmp.dir",updateHelper.getAntProjectHelper().resolvePath(evaluator.getProperty(ProjectProperties.BUILD_DIR))); //NOI18N |
512 |
updateJavaRunnerClasspath(command, execProperties); |
537 |
updateJavaRunnerClasspath(command, execProperties); |
|
|
538 |
task = |
513 |
JavaRunner.execute(command.equals(SingleMethod.COMMAND_RUN_SINGLE_METHOD) ? JavaRunner.QUICK_TEST : JavaRunner.QUICK_TEST_DEBUG, |
539 |
JavaRunner.execute(command.equals(SingleMethod.COMMAND_RUN_SINGLE_METHOD) ? JavaRunner.QUICK_TEST : JavaRunner.QUICK_TEST_DEBUG, |
514 |
execProperties); |
540 |
execProperties); |
515 |
} catch (IOException ex) { |
541 |
} catch (IOException ex) { |
Lines 547-553
Link Here
|
547 |
cb2.antTargetInvocationStarted(command, context); |
573 |
cb2.antTargetInvocationStarted(command, context); |
548 |
} |
574 |
} |
549 |
try { |
575 |
try { |
550 |
ActionUtils.runTarget(buildFo, targetNames, p).addTaskListener(new TaskListener() { |
576 |
task = ActionUtils.runTarget(buildFo, targetNames, p); |
|
|
577 |
task.addTaskListener(new TaskListener() { |
551 |
@Override |
578 |
@Override |
552 |
public void taskFinished(Task task) { |
579 |
public void taskFinished(Task task) { |
553 |
try { |
580 |
try { |
Lines 1352-1358
Link Here
|
1352 |
return srcDir; |
1379 |
return srcDir; |
1353 |
} |
1380 |
} |
1354 |
|
1381 |
|
1355 |
private void bypassAntBuildScript(String command, Lookup context, Map<String, Object> p) throws IllegalArgumentException { |
1382 |
private void bypassAntBuildScript(String command, Lookup context, Map<String, Object> p, AtomicReference<ExecutorTask> task) throws IllegalArgumentException { |
1356 |
boolean run = true; |
1383 |
boolean run = true; |
1357 |
boolean hasMainMethod = true; |
1384 |
boolean hasMainMethod = true; |
1358 |
|
1385 |
|
Lines 1386-1397
Link Here
|
1386 |
updateJavaRunnerClasspath(command, p); |
1413 |
updateJavaRunnerClasspath(command, p); |
1387 |
if (run) { |
1414 |
if (run) { |
1388 |
copyMultiValue(ProjectProperties.APPLICATION_ARGS, p); |
1415 |
copyMultiValue(ProjectProperties.APPLICATION_ARGS, p); |
1389 |
JavaRunner.execute(debug ? JavaRunner.QUICK_DEBUG : JavaRunner.QUICK_RUN, p); |
1416 |
task.set(JavaRunner.execute(debug ? JavaRunner.QUICK_DEBUG : JavaRunner.QUICK_RUN, p)); |
1390 |
} else { |
1417 |
} else { |
1391 |
if (hasMainMethod) { |
1418 |
if (hasMainMethod) { |
1392 |
JavaRunner.execute(debug ? JavaRunner.QUICK_DEBUG : JavaRunner.QUICK_RUN, p); |
1419 |
task.set(JavaRunner.execute(debug ? JavaRunner.QUICK_DEBUG : JavaRunner.QUICK_RUN, p)); |
1393 |
} else { |
1420 |
} else { |
1394 |
JavaRunner.execute(debug ? JavaRunner.QUICK_TEST_DEBUG : JavaRunner.QUICK_TEST, p); |
1421 |
task.set(JavaRunner.execute(debug ? JavaRunner.QUICK_TEST_DEBUG : JavaRunner.QUICK_TEST, p)); |
1395 |
} |
1422 |
} |
1396 |
} |
1423 |
} |
1397 |
} catch (IOException ex) { |
1424 |
} catch (IOException ex) { |