void (final Task task) { final Application app = ApplicationManager.getApplication(); if (task.isHeadless()) { // for headless tasks we need to ensure async execution. // Otherwise, calls to AntConfiguration.getInstance() from the task will cause SOE app.invokeLater(task::queue); } else { task.queue(); } }