void () { ProjectTaskManagerImpl projectTaskManager = (ProjectTaskManagerImpl)ProjectTaskManager.getInstance(myProject); projectTaskManager.addListener(new ProjectTaskManagerListener() { @Override public void beforeRun(@NotNull ProjectTaskContext context) throws ExecutionException { if (!doExecuteBuildPhaseTriggers(true, context)) { throw new ExecutionException(ExternalSystemBundle.message("dialog.message.before.build.triggering.task.failed")); } } @Override public void afterRun(@NotNull ProjectTaskManager.Result result) throws ExecutionException { if (!doExecuteBuildPhaseTriggers(false, result.getContext())) { throw new ExecutionException(ExternalSystemBundle.message("dialog.message.after.build.triggering.task.failed")); } } }); fireTasksChanged(); }