return AbstractTask.injectIntoNewInstance(project, name, new Callable<TaskInternal>() {
public TaskInternal call() throws Exception {
try {
return constructor.newInstance(params);
} catch (InvocationTargetException e) {
throw new TaskInstantiationException(String.format("Could not create task of type '%s'.", type.getSimpleName()),
e.getCause());
} catch (Exception e) {
throw new TaskInstantiationException(String.format("Could not create task of type '%s'.", type.getSimpleName()), e);
}
}
});
}