use of com.intellij.execution.configurations.RunProfileWithCompileBeforeLaunchOption in project intellij-community by JetBrains.
the class CompileStepBeforeRun method doMake.
static boolean doMake(final Project myProject, final RunConfiguration configuration, final ExecutionEnvironment env, final boolean ignoreErrors, final boolean forceMakeProject) {
if (!(configuration instanceof RunProfileWithCompileBeforeLaunchOption)) {
return true;
}
if (configuration instanceof RunConfigurationBase && ((RunConfigurationBase) configuration).excludeCompileBeforeLaunchOption()) {
return true;
}
final RunProfileWithCompileBeforeLaunchOption runConfiguration = (RunProfileWithCompileBeforeLaunchOption) configuration;
final Ref<Boolean> result = new Ref<>(Boolean.FALSE);
try {
final Semaphore done = new Semaphore();
done.down();
final ProjectTaskNotification callback = new ProjectTaskNotification() {
public void finished(@NotNull ProjectTaskResult executionResult) {
if ((executionResult.getErrors() == 0 || ignoreErrors) && !executionResult.isAborted()) {
result.set(Boolean.TRUE);
}
done.up();
}
};
TransactionGuard.submitTransaction(myProject, () -> {
ProjectTask projectTask;
Object sessionId = ExecutionManagerImpl.EXECUTION_SESSION_ID_KEY.get(env);
final ProjectTaskManager projectTaskManager = ProjectTaskManager.getInstance(myProject);
if (forceMakeProject) {
// user explicitly requested whole-project make
projectTask = projectTaskManager.createAllModulesBuildTask(true, myProject);
} else {
final Module[] modules = runConfiguration.getModules();
if (modules.length > 0) {
for (Module module : modules) {
if (module == null) {
LOG.error("RunConfiguration should not return null modules. Configuration=" + runConfiguration.getName() + "; class=" + runConfiguration.getClass().getName());
}
}
projectTask = projectTaskManager.createModulesBuildTask(modules, true, true, true);
} else {
projectTask = projectTaskManager.createAllModulesBuildTask(true, myProject);
}
}
if (!myProject.isDisposed()) {
projectTaskManager.run(new ProjectTaskContext(sessionId, configuration), projectTask, callback);
} else {
done.up();
}
});
done.waitFor();
} catch (Exception e) {
return false;
}
return result.get();
}
Aggregations